1
Fork 0

allow indexing into constant arrays

This commit is contained in:
Oliver Schneider 2015-11-18 10:57:52 +01:00
parent af5d9d65e7
commit 6683fa4d42
10 changed files with 190 additions and 28 deletions

View file

@ -9,7 +9,10 @@
// except according to those terms.
const FOO: [u32; 3] = [1, 2, 3];
const BAR: u32 = FOO[5]; //~ ERROR const index-expr is out of bounds
const BAR: u32 = FOO[5]; // no error, because the error below occurs before regular const eval
const BLUB: [u32; FOO[4]] = [5, 6];
//~^ ERROR array length constant evaluation error: array index out of bounds [E0250]
fn main() {
let _ = BAR;