parent
6eaacd3391
commit
ea6d2d53db
|
@ -15,7 +15,7 @@ struct array_buffer {
|
|||
fn (mut a array_buffer) make_copy() {
|
||||
if a.index_start != 0 || a.has_slice {
|
||||
mut new_arr := JS.makeEmtpyJSArray()
|
||||
for mut i in 0 .. a.len {
|
||||
for i in 0 .. a.len {
|
||||
#new_arr.push(a.val.get(i))
|
||||
|
||||
mut x := i
|
||||
|
|
|
@ -153,6 +153,9 @@ fn (mut p Parser) for_stmt() ast.Stmt {
|
|||
return p.error_with_pos('cannot declare index variable with range `for`',
|
||||
key_var_pos)
|
||||
}
|
||||
if val_is_mut {
|
||||
return p.error_with_pos('variable in range `for` cannot be mut', mut_pos)
|
||||
}
|
||||
} else {
|
||||
// this type will be set in checker
|
||||
p.scope.register(ast.Var{
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
vlib/v/parser/tests/for.vv:1:5: error: cannot declare index variable with range `for`
|
||||
1 | for i, k in 0..5 {
|
||||
| ^
|
||||
2 | }
|
|
@ -0,0 +1,4 @@
|
|||
vlib/v/parser/tests/for_index_in_range.vv:1:5: error: cannot declare index variable with range `for`
|
||||
1 | for i, k in 0..5 {
|
||||
| ^
|
||||
2 | }
|
|
@ -0,0 +1,4 @@
|
|||
vlib/v/parser/tests/for_mut_in_range.vv:1:5: error: variable in range `for` cannot be mut
|
||||
1 | for mut i in 0..5 {
|
||||
| ~~~
|
||||
2 | }
|
|
@ -0,0 +1,2 @@
|
|||
for mut i in 0..5 {
|
||||
}
|
Loading…
Reference in New Issue