1 | } |
2 | if node.cond in [ast.Ident, ast.IntegerLiteral, ast.StringLiteral, ast.FloatLiteral] |
3 | || (node.cond is ast.SelectorExpr |
4 | - && (node.cond as ast.SelectorExpr).or_block.kind == .absent) { |
5 | + && (node.cond as ast.SelectorExpr).or_block.kind == .absent |
6 | + && ((node.cond as ast.SelectorExpr).expr !is ast.CallExpr |
7 | + || ((node.cond as ast.SelectorExpr).expr as ast.CallExpr).or_block.kind == .absent)) { |
8 | cond_var = g.expr_string(node.cond) |
9 | } else { |
10 | line := if is_expr { |
11 |
1 | new file mode 100644 |
2 | +struct Foo { |
3 | +pub: |
4 | + a int |
5 | +} |
6 | + |
7 | +fn foo() !Foo { |
8 | + return Foo{1} |
9 | +} |
10 | + |
11 | +fn bar() ?Foo { |
12 | + return Foo{2} |
13 | +} |
14 | + |
15 | +fn test_main() { |
16 | + match foo()!.a { |
17 | + 1 { |
18 | + assert true |
19 | + } |
20 | + else { |
21 | + assert false |
22 | + } |
23 | + } |
24 | + |
25 | + match bar()?.a { |
26 | + 2 { |
27 | + assert true |
28 | + } |
29 | + else { |
30 | + assert false |
31 | + } |
32 | + } |
33 | +} |
34 |