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

parser: fix use blank ident as value

This commit is contained in:
joe-conigliaro 2019-12-11 05:35:59 +11:00 committed by Alexander Medvednikov
parent 9726e18c0a
commit 4e69c40e12
2 changed files with 4 additions and 3 deletions

View File

@ -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]

View File

@ -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('&')
}