v.parser: fix `if a == Abc{} {` (#11092)
parent
94c321c80d
commit
1d3786ff1e
|
@ -2147,6 +2147,10 @@ pub fn (mut p Parser) name_expr() ast.Expr {
|
|||
return map_init
|
||||
}
|
||||
return p.struct_init(false) // short_syntax: false
|
||||
} else if p.peek_tok.kind == .lcbr && p.inside_if && lit0_is_capital && !known_var
|
||||
&& language == .v {
|
||||
// if a == Foo{} {...}
|
||||
return p.struct_init(false)
|
||||
} else if p.peek_tok.kind == .dot && (lit0_is_capital && !known_var && language == .v) {
|
||||
// T.name
|
||||
if p.is_generic_name() {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
struct Foo {
|
||||
bar int
|
||||
}
|
||||
|
||||
fn test_if_expr_with_struct_init() {
|
||||
a := Foo{}
|
||||
if a == Foo{} {
|
||||
println(true)
|
||||
assert true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue