Closed
Description
This compiles:
static i: int = 4;
fn main () {
let x: [int, ..i] = [1, 2, 3, 4];
println(fmt!("%?", x));
}
But this doesn't:
enum Foo {
Bar = 4,
}
static i: int = Bar as int;
fn main () {
let x: [int, ..i] = [1, 2, 3, 4];
println(fmt!("%?", x));
}
test2.rs:7:11: 7:21 error: expected constant expr for vector length: Can't cast str to int
test2.rs:7 let x: [int, ..i] = [1, 2, 3, 4];
^~~~~~~~~~
That error message doesn't seem to make sense, but that may be because it's just confused - I also get this error message in other circumstances, and I don't understand what the difference is:
src/info/builtin.rs:79:11: 79:52 error: expected constant expr for vector length: Non-constant path in constant expr
src/info/builtin.rs:79 static db: [[Option<&'static str>, ..ncap], ..nterm] = [
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~