1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compiler: prompts an error when accessing a map with wrong type

This commit is contained in:
Henrixounez 2019-08-13 19:13:39 +02:00 committed by Alexander Medvednikov
parent 7b48f7ac9e
commit 437ba14521

View File

@ -1969,7 +1969,11 @@ fn (p mut Parser) index_expr(typ_ string, fn_ph int) string {
}
}
else {
p.expression()
T := p.table.find_type(p.expression())
// TODO: Get the key type of the map instead of only string.
if is_map && T.parent != 'string' {
p.check_types(T.name, 'string')
}
}
p.check(.rsbr)
// if (is_str && p.builtin_mod) || is_ptr || is_fixed_arr && ! (is_ptr && is_arr) {