diff --git a/vlib/compiler/for.v b/vlib/compiler/for.v index 2119d6b1c8..e884666eef 100644 --- a/vlib/compiler/for.v +++ b/vlib/compiler/for.v @@ -22,6 +22,7 @@ fn (p mut Parser) for_st() { else if next_tok == .decl_assign || next_tok == .assign || p.tok == .semicolon { p.genln('for (') if next_tok == .decl_assign { + p.check_not_reserved() p.var_decl() } else if p.tok != .semicolon { diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 753ac8eafc..97398625a7 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -697,8 +697,8 @@ fn (p mut Parser) check_string() string { } fn (p mut Parser) check_not_reserved () { - if p.lit in Reserved_Types { - p.error('`$p.lit` can\'t be used as name') + if Reserved_Types[p.lit] { + p.error('`$p.lit` can\'t be used as name') } }