diff --git a/vlib/compiler/cflags.v b/vlib/compiler/cflags.v index 8b6f1cd47a..5e658b1042 100644 --- a/vlib/compiler/cflags.v +++ b/vlib/compiler/cflags.v @@ -93,7 +93,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { if flag[0] == `-` { for f in allowed_flags { i := 1+f.len - if i < flag.len && f == flag.substr(1,i) { + if i <= flag.len && f == flag.substr(1,i) { name = flag.left(i).trim_space() flag = flag.right(i).trim_space() break @@ -137,6 +137,7 @@ fn (table mut Table) parse_cflag(cflag string, mod string) { break } } + return } //TODO: implement msvc specific c_options_before_target and c_options_after_target ... diff --git a/vlib/compiler/comptime.v b/vlib/compiler/comptime.v index d552b391c9..01e59da646 100644 --- a/vlib/compiler/comptime.v +++ b/vlib/compiler/comptime.v @@ -179,12 +179,14 @@ fn (p mut Parser) chash() { // println('chsh() file=$p.file hash="$hash"') p.next() if hash.starts_with('flag ') { - mut flag := hash.right(5) - // expand `@VROOT` `@VMOD` to absolute path - flag = flag.replace('@VROOT', p.vroot) - flag = flag.replace('@VMOD', v_modules_path) - //p.log('adding flag "$flag"') - p.table.parse_cflag(flag, p.mod) + p.first_pass() { + mut flag := hash.right(5) + // expand `@VROOT` `@VMOD` to absolute path + flag = flag.replace('@VROOT', p.vroot) + flag = flag.replace('@VMOD', v_modules_path) + //p.log('adding flag "$flag"') + p.table.parse_cflag(flag, p.mod) + } return } if hash.starts_with('include') { diff --git a/vlib/compiler/gen_c.v b/vlib/compiler/gen_c.v index abc2664f6c..d6527ff40b 100644 --- a/vlib/compiler/gen_c.v +++ b/vlib/compiler/gen_c.v @@ -92,14 +92,23 @@ fn (p mut Parser) gen_blank_identifier_assign() { assign_error_tok_idx := p.token_idx p.check_name() p.check_space(.assign) - expr := p.lit is_indexer := p.peek() == .lsbr - is_fn_call := p.peek() == .lpar || (p.peek() == .dot && p.tokens[p.token_idx+2].tok == .lpar) - if !is_indexer && !is_fn_call { - p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx) + mut expr := p.lit + mut is_fn_call := p.peek() == .lpar + if !is_fn_call { + mut i := p.token_idx+1 + for (p.tokens[i].tok == .dot || p.tokens[i].tok == .name) && + p.tokens[i].lit != '_' { + expr += if p.tokens[i].tok == .dot { '.' } else { p.tokens[i].lit } + i++ + } + is_fn_call = p.tokens[i].tok == .lpar } pos := p.cgen.add_placeholder() mut typ := p.bool_expression() + if !is_indexer && !is_fn_call { + p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx) + } tmp := p.get_tmp() // handle or if p.tok == .key_orelse { diff --git a/vlib/compiler/gen_js.v b/vlib/compiler/gen_js.v index b09c3b6f68..299f3d783e 100644 --- a/vlib/compiler/gen_js.v +++ b/vlib/compiler/gen_js.v @@ -38,13 +38,22 @@ fn (p mut Parser) gen_blank_identifier_assign() { assign_error_tok_idx := p.token_idx p.check_name() p.check_space(.assign) - expr := p.lit is_indexer := p.peek() == .lsbr - is_fn_call := p.peek() == .lpar || (p.peek() == .dot && p.tokens[p.token_idx+2].tok == .lpar) + mut expr := p.lit + mut is_fn_call := p.peek() == .lpar + if !is_fn_call { + mut i := p.token_idx+1 + for (p.tokens[i].tok == .dot || p.tokens[i].tok == .name) && + p.tokens[i].lit != '_' { + expr += if p.tokens[i].tok == .dot { '.' } else { p.tokens[i].lit } + i++ + } + is_fn_call = p.tokens[i].tok == .lpar + } + p.bool_expression() if !is_indexer && !is_fn_call { p.error_with_token_index('assigning `$expr` to `_` is redundant', assign_error_tok_idx) } - p.bool_expression() or_else := p.tok == .key_orelse //tmp := p.get_tmp() if or_else {