diff --git a/vlib/v/parser/expr.v b/vlib/v/parser/expr.v index 7afe792a53..5541be252e 100644 --- a/vlib/v/parser/expr.v +++ b/vlib/v/parser/expr.v @@ -325,11 +325,6 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr { node = p.map_init() p.check(.rcbr) } - .key_struct { - // Anonymous struct - p.next() - return p.struct_init('', .anon) - } .key_fn { if p.expecting_type { // Anonymous function type @@ -362,6 +357,11 @@ pub fn (mut p Parser) check_expr(precedence int) ?ast.Expr { } } else { + if p.tok.kind == .key_struct && p.peek_tok.kind == .lcbr { + // Anonymous struct + p.next() + return p.struct_init('', .anon) + } if p.tok.kind != .eof && !(p.tok.kind == .rsbr && p.inside_asm) { // eof should be handled where it happens return none