From 6bcd0fd9ccd164845e7e6e39b90345b28099146b Mon Sep 17 00:00:00 2001 From: lorenzo pirro Date: Thu, 7 Nov 2019 16:45:38 +0100 Subject: [PATCH] optimize reserved type check --- vlib/compiler/for.v | 1 + vlib/compiler/parser.v | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) 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') } }