@@ -2398,8 +2398,8 @@ fn (mut g Gen) call_args(node ast.CallExpr) {
23982398 }
23992399 }
24002400 // only v variadic, C variadic args will be appended like normal args
2401- is_variadic := expected_types.len > 0 && expected_types.last (). has_flag (.variadic)
2402- && node. language == .v
2401+ is_variadic := node. language == .v && node.is_variadic && expected_types.len > 0
2402+ && expected_types. last (). has_flag (.variadic)
24032403 mut already_decomposed := false
24042404 for i, arg in args {
24052405 if is_variadic && i == expected_types.len - 1 {
@@ -2568,6 +2568,14 @@ fn (mut g Gen) call_args(node ast.CallExpr) {
25682568 false )
25692569 } else {
25702570 noscan := g.check_noscan (arr_info.elem_type)
2571+ is_option := arr_info.elem_type.has_flag (.option)
2572+ tmp_var := if is_option { g.new_tmp_var () } else { '' }
2573+ base_type := g.base_type (varg_type)
2574+ tmp := if is_option { g.go_before_last_stmt () } else { '' }
2575+ if is_option {
2576+ g.writeln ('${g .styp (varg_type )} ${tmp_var };' )
2577+ g.write ('builtin___option_ok((${base_type }[]) {' )
2578+ }
25712579 g.write ('builtin__new_array_from_c_array${noscan }(${variadic_count }, ${variadic_count }, sizeof(${elem_type }), _MOV((${elem_type }[${variadic_count }]){' )
25722580 for j in arg_nr .. args.len {
25732581 g.ref_or_deref_arg (args[j], arr_info.elem_type, node.language,
@@ -2577,6 +2585,11 @@ fn (mut g Gen) call_args(node ast.CallExpr) {
25772585 }
25782586 }
25792587 g.write ('}))' )
2588+ if is_option {
2589+ g.writeln (' }, (${option_name }*)&${tmp_var }, sizeof(${base_type }));' )
2590+ g.write (tmp)
2591+ g.write (tmp_var)
2592+ }
25802593 }
25812594 }
25822595 } else {
0 commit comments