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

pull/1606/head
Henrixounez 2019-08-13 19:13:39 +02:00 committed by Alexander Medvednikov
parent 7b48f7ac9e
commit 437ba14521
1 changed files with 5 additions and 1 deletions

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) {