checker: for in index type error position

pull/4410/head
Daniel Däschle 2020-04-14 19:37:56 +02:00 committed by GitHub
parent deab448d93
commit 50871d1a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -954,7 +954,7 @@ fn (c mut Checker) stmt(node ast.Stmt) {
value_type := c.table.value_type(typ)
if value_type == table.void_type {
typ_sym := c.table.get_type_symbol(typ)
c.error('for in: cannot index `$typ_sym.name`', it.pos)
c.error('for in: cannot index `$typ_sym.name`', expr_pos(it.cond))
}
it.cond_type = typ
it.kind = sym.kind

View File

@ -0,0 +1,6 @@
vlib/v/checker/tests/inout/for-in-index-type.v:2:11: error: for in: cannot index `int`
1| fn main() {
2| for a in 52 {
~~
3| println(a)
4| }

View File

@ -0,0 +1,5 @@
fn main() {
for a in 52 {
println(a)
}
}