From 4e69c40e12583d167f351308fb6a969a881c50fd Mon Sep 17 00:00:00 2001 From: joe-conigliaro Date: Wed, 11 Dec 2019 05:35:59 +1100 Subject: [PATCH] parser: fix use blank ident as value --- vlib/compiler/expression.v | 4 ++++ vlib/compiler/parser.v | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vlib/compiler/expression.v b/vlib/compiler/expression.v index 5883e79b22..ad75dbdbc3 100644 --- a/vlib/compiler/expression.v +++ b/vlib/compiler/expression.v @@ -167,6 +167,10 @@ fn (p mut Parser) name_expr() string { return temp_type } mut name := p.lit + // blank identifier (not var) + if name == '_' { + p.error('cannot use `_` as value') + } // generic type check if name in p.cur_fn.dispatch_of.inst.keys() { name = p.cur_fn.dispatch_of.inst[name] diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index b0606c3856..e5bd2e58ee 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -1619,9 +1619,6 @@ fn (p mut Parser) get_struct_type(name_ string, is_c bool, is_ptr bool) string { fn (p mut Parser) get_var_type(name string, is_ptr bool, deref_nr int) string { v := p.find_var_check_new_var(name) or { return "" } - if name == '_' { - p.error('cannot use `_` as value') - } if is_ptr { p.gen('&') }