File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -5517,10 +5517,9 @@ fn (mut g Gen) concat_expr(node ast.ConcatExpr) {
5517
5517
g.write ('(${styp} ){' )
5518
5518
for i, expr in node.vals {
5519
5519
g.write ('.arg${i} =' )
5520
- if types[i].has_flag (.option) && expr.is_literal () {
5521
- g.write ('{.data=' )
5522
- g.expr (expr)
5523
- g.write ('}' )
5520
+ expr_typ := g.get_expr_type (expr)
5521
+ if expr_typ != ast.void_type && types[i].has_flag (.option) {
5522
+ g.expr_with_opt (expr, expr_typ, types[i])
5524
5523
} else {
5525
5524
old_left_is_opt := g.left_is_opt
5526
5525
g.left_is_opt = true
@@ -5942,7 +5941,7 @@ fn (mut g Gen) return_stmt(node ast.Return) {
5942
5941
multi_unpack + = g.go_before_last_stmt ()
5943
5942
g.write (line)
5944
5943
expr_styp := g.base_type (call_expr.return_type)
5945
- tmp = ( '(*(${expr_styp} *)${tmp} .data)' )
5944
+ tmp = '(*(${expr_styp} *)${tmp} .data)'
5946
5945
}
5947
5946
expr_types := expr_sym.mr_info ().types
5948
5947
for j, _ in expr_types {
Original file line number Diff line number Diff line change @@ -472,6 +472,21 @@ fn (mut g Gen) get_expr_type(cond ast.Expr) ast.Type {
472
472
}
473
473
}
474
474
}
475
+ ast.IntegerLiteral {
476
+ return ast.int_type
477
+ }
478
+ ast.BoolLiteral {
479
+ return ast.bool_type
480
+ }
481
+ ast.StringLiteral {
482
+ return ast.string_type
483
+ }
484
+ ast.CharLiteral {
485
+ return ast.char_type
486
+ }
487
+ ast.FloatLiteral {
488
+ return ast.f64_ type
489
+ }
475
490
else {
476
491
return ast.void_type
477
492
}
Original file line number Diff line number Diff line change
1
+ fn fails (i int ) ! (int , ? int ) {
2
+ return error ('fails' )
3
+ }
4
+
5
+ fn test_main () {
6
+ a2 , b2 := fails (2 ) or { 22 , 22 }
7
+ c2 := b2 ? as int
8
+ assert b2 != none
9
+ assert a2 == c2
10
+ }
You can’t perform that action at this time.
0 commit comments