#E0091: invalid broadcast
A broadcast call f.(xs) maps over a List, Slice or array, and arrays given together must have the same length. Pass collections of matching length. One dot expression takes core collections or Broadcastable types (Array), not both: make a list an array with Array::from_list(xs, [xs.len()]). .= / .+= .. write into a List, fixed array or Array (a view of one included), whose shape the operands must fit; .?? needs a container operand.
fn add(a: i32, b: i32) -> i32 { a + b }
let xs: [i32; 3] = [1, 2, 3];
let ys: [i32; 4] = [10, 20, 30, 40];
println(f"{add.(xs, ys):?}");
error[E0091]: broadcast over arrays of lengths 3 and 4 --> main.nabi:5:12 | 5 | println(f"{add.(xs, ys):?}"); | ^^^^^^^^^^^^
Pass arrays of the same length:
fn add(a: i32, b: i32) -> i32 { a + b }
let xs: [i32; 3] = [1, 2, 3];
let ys: [i32; 3] = [10, 20, 30];
println(f"{add.(xs, ys):?}");
[11, 22, 33]
The same code covers the other misuses of dot syntax, each with a help that writes the fix. One dot expression takes core collections (List, Slice, fixed arrays) or Broadcastable types such as Array, not both:
use core::array::Array;
let xs = [1.0, 2.0];
let a = Array::from_list(xs, [xs.len()]);
let b: Array<f64, 1> = [10.0, 20.0];
println(f"{a .+ b:?}");
[11.0, 22.0]
.= and .+= .. write into a List, a fixed array or an Array (a view of one included), whose shape the operands must fit; a Slice is read-only, and any other target takes the operation written out (x = x .+ ..;). .?? needs a container operand; for single values write x ?? y.
Related: E0048 wrong number of arguments
Found a mistake? Edit this page on GitHub. Last updated