mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
parent
b7b1c2e2e3
commit
f80fc37775
@ -3118,7 +3118,7 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ
|
||||
}
|
||||
if (exp_sym.kind == .function && !expected_type.has_option_or_result())
|
||||
|| (g.inside_struct_init && expected_type == ast.voidptr_type
|
||||
&& expected_type != got_type_raw) {
|
||||
&& expected_type != got_type_raw && expr !is ast.StructInit) {
|
||||
g.write('(voidptr)')
|
||||
}
|
||||
// no cast
|
||||
|
22
vlib/v/tests/structs/struct_init_passing_test.v
Normal file
22
vlib/v/tests/structs/struct_init_passing_test.v
Normal file
@ -0,0 +1,22 @@
|
||||
module main
|
||||
|
||||
import json
|
||||
|
||||
struct Definition {
|
||||
version u8
|
||||
}
|
||||
|
||||
struct Logic {
|
||||
run fn () i8 @[required]
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
logic := Logic{
|
||||
run: fn () i8 {
|
||||
json.encode_pretty(Definition{})
|
||||
return 0
|
||||
}
|
||||
}
|
||||
logic.run()
|
||||
assert true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user