Summary
The repeat array-literal value form [value; N] does not parse. Only explicit element lists [a, b, c] are accepted for array values, even though the array type syntax is [T; N]. The resulting diagnostic is also misleading.
Reproduction
pub fn f() -> i64 {
let a: [i64; 3] = [5; 3]; // repeat literal
let i: i32 = 1;
return a[i];
}
Parse error: AST building failed due to errors:
2:25: expected RBracket
2:28: expected Semi
2:28: expected a statement
Same failure with struct elements (let a: [V; 3] = [d; 3];). Explicit lists work: let a: [i64; 3] = [5, 5, 5]; compiles fine.
Impact
Building a fixed-size array of N identical (or placeholder) elements requires enumerating all N explicitly. For example, padding a fixed 16-slot scene array to a known size means writing out every dummy element by hand, where [dummy; 16] would be natural.
Expected
Either support [value; N] for value initialization (it mirrors the [T; N] type syntax and matches the Rust-like surface), or emit a clear diagnostic such as "repeat array literals are not supported; list elements explicitly" instead of expected RBracket.
Environment: infc 0.0.1 (commit df45600, ABI 1.0), Inferara/inference @ d82d935 (wasm-linker). Found while implementing a fixed-point ray tracer entirely in Inference (scratch/raytracing-in-one-weekend).
Summary
The repeat array-literal value form
[value; N]does not parse. Only explicit element lists[a, b, c]are accepted for array values, even though the array type syntax is[T; N]. The resulting diagnostic is also misleading.Reproduction
Same failure with struct elements (
let a: [V; 3] = [d; 3];). Explicit lists work:let a: [i64; 3] = [5, 5, 5];compiles fine.Impact
Building a fixed-size array of N identical (or placeholder) elements requires enumerating all N explicitly. For example, padding a fixed 16-slot scene array to a known size means writing out every dummy element by hand, where
[dummy; 16]would be natural.Expected
Either support
[value; N]for value initialization (it mirrors the[T; N]type syntax and matches the Rust-like surface), or emit a clear diagnostic such as "repeat array literals are not supported; list elements explicitly" instead ofexpected RBracket.Environment:
infc0.0.1 (commitdf45600, ABI 1.0),Inferara/inference@d82d935(wasm-linker). Found while implementing a fixed-point ray tracer entirely in Inference (scratch/raytracing-in-one-weekend).