| 1 | fn test_reference_array_init() { |
| 2 | mut b := &[5, 6, 7] |
| 3 | assert '${b}' == '&[5, 6, 7]' |
| 4 | mut b_fixed := &[5, 6, 7]! |
| 5 | assert '${b_fixed}' == '&[5, 6, 7]' |
| 6 | { |
| 7 | mut a := [1, 2, 3] |
| 8 | // TODO: this should probably produce a notice at least, |
| 9 | // (without unsafe{&a}), since it takes the address of something |
| 10 | // on the stack, that will very soon be out of scope, even |
| 11 | // though it is still in the same function: |
| 12 | b = &a |
| 13 | b_fixed = &[1, 2, 3]! |
| 14 | } |
| 15 | println(b) |
| 16 | assert '${b}' == '&[1, 2, 3]' |
| 17 | assert '${b_fixed}' == '&[1, 2, 3]' |
| 18 | } |
| 19 | |