We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aadb0e9 commit 6dcedaeCopy full SHA for 6dcedae
vlib/v/gen/c/if.v
@@ -76,6 +76,7 @@ fn (mut g Gen) need_tmp_var_in_expr(expr ast.Expr) bool {
76
return true
77
}
78
79
+ return expr.expected_arg_types.any(it.has_flag(.option))
80
81
ast.CastExpr {
82
return g.need_tmp_var_in_expr(expr.expr)
vlib/v/tests/fns/call_option_param_test.v
@@ -0,0 +1,15 @@
1
+pub fn new_group(t ?Texts) Group {
2
+ return Group{}
3
+}
4
+
5
+struct Group {
6
7
8
+struct Texts {
9
10
11
+fn test_main() {
12
+ a := 0
13
+ _ := if a != 0 { new_group(Texts{}) } else { Group{} }
14
+ _ := if a != 0 { new_group(none) } else { Group{} }
15
0 commit comments