mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.parser: fix if a == Abc{} {
(#11092)
This commit is contained in:
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() {
|
||||
|
11
vlib/v/tests/if_expr_with_struct_init_test.v
Normal file
11
vlib/v/tests/if_expr_with_struct_init_test.v
Normal file
@ -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
Block a user