File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -722,11 +722,25 @@ fn (mut g Gen) infix_expr_arithmetic_op(node ast.InfixExpr) {
722
722
g.gen_plain_infix_expr (node)
723
723
return
724
724
}
725
+
726
+ mut right_var := ''
727
+ if node.right is ast.Ident && (node.right as ast.Ident ).or_expr.kind != .absent {
728
+ cur_line := g.go_before_stmt (0 ).trim_space ()
729
+ right_var = g.new_tmp_var ()
730
+ g.write ('${g.typ(right.typ)} ${right_var} = ' )
731
+ g.op_arg (node.right, method.params[1 ].typ, right.typ)
732
+ g.writeln (';' )
733
+ g.write (cur_line)
734
+ }
725
735
g.write (method_name)
726
736
g.write ('(' )
727
737
g.op_arg (node.left, method.params[0 ].typ, left.typ)
728
- g.write (', ' )
729
- g.op_arg (node.right, method.params[1 ].typ, right.typ)
738
+ if right_var != '' {
739
+ g.write (', ${right_var} ' )
740
+ } else {
741
+ g.write (', ' )
742
+ g.op_arg (node.right, method.params[1 ].typ, right.typ)
743
+ }
730
744
g.write (')' )
731
745
}
732
746
}
Original file line number Diff line number Diff line change
1
+ fn test_str_concat () {
2
+ opt := ? string (none )
3
+ x := match 1 {
4
+ 0 { 'abc' }
5
+ else { 'def' }
6
+ } + opt or { '!!!' }
7
+ assert x == 'def!!!'
8
+
9
+ y := opt or { '!!!' } + match 1 {
10
+ 0 { 'abc' }
11
+ else { 'def' }
12
+ }
13
+ println (y)
14
+ assert y == '!!!def'
15
+ }
You can’t perform that action at this time.
0 commit comments