mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: fix reference var followed by block expr (#11456)
This commit is contained in:
parent
91c6eeeae5
commit
af75789bbf
@ -2170,7 +2170,7 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
||||
} else if (p.peek_tok.kind == .lcbr || (p.peek_tok.kind == .lt && lit0_is_capital))
|
||||
&& (!p.inside_match || (p.inside_select && prev_tok_kind == .arrow && lit0_is_capital))
|
||||
&& !p.inside_match_case && (!p.inside_if || p.inside_select)
|
||||
&& (!p.inside_for || p.inside_select) { // && (p.tok.lit[0].is_capital() || p.builtin_mod) {
|
||||
&& (!p.inside_for || p.inside_select) && !known_var { // && (p.tok.lit[0].is_capital() || p.builtin_mod) {
|
||||
// map.v has struct literal: map{field: expr}
|
||||
if p.peek_tok.kind == .lcbr && !(p.builtin_mod
|
||||
&& p.file_base in ['map.v', 'map_d_gcboehm_opt.v']) && p.tok.lit == 'map' {
|
||||
|
8
vlib/v/tests/reference_var_followed_block_expr.v
Normal file
8
vlib/v/tests/reference_var_followed_block_expr.v
Normal file
@ -0,0 +1,8 @@
|
||||
fn test_reference_var_followed_block_expr() {
|
||||
mut b := [5, 6, 7]
|
||||
mut c := &b
|
||||
{
|
||||
}
|
||||
println(c)
|
||||
assert '$c' == '&[5, 6, 7]'
|
||||
}
|
Loading…
Reference in New Issue
Block a user