mirror of
https://github.com/vlang/v.git
synced 2025-09-13 01:16:02 -04:00
This commit is contained in:
parent
0b792c541a
commit
13fbf35f66
@ -189,8 +189,8 @@ fn (mut c Checker) assign_stmt(mut node ast.AssignStmt) {
|
||||
if is_decl || is_shared_re_assign {
|
||||
// check generic struct init and return unwrap generic struct type
|
||||
if mut right is ast.StructInit {
|
||||
c.expr(mut right)
|
||||
if right.typ.has_flag(.generic) {
|
||||
c.expr(mut right)
|
||||
right_type = right.typ
|
||||
}
|
||||
} else if mut right is ast.PrefixExpr {
|
||||
|
25
vlib/v/tests/struct_field_init_with_generic_fn_test.v
Normal file
25
vlib/v/tests/struct_field_init_with_generic_fn_test.v
Normal file
@ -0,0 +1,25 @@
|
||||
struct ClassInfo {
|
||||
func fn () = unsafe { nil }
|
||||
}
|
||||
|
||||
pub fn func2[T]() {
|
||||
}
|
||||
|
||||
pub fn func1[T]() {
|
||||
ci := ClassInfo{
|
||||
func: func2[T]
|
||||
}
|
||||
ci.func()
|
||||
}
|
||||
|
||||
struct Struct1 {}
|
||||
|
||||
struct Struct2 {}
|
||||
|
||||
fn test_struct_field_init_with_generic_fn() {
|
||||
func1[i32]()
|
||||
func1[bool]()
|
||||
func1[Struct1]()
|
||||
func1[Struct2]()
|
||||
assert true
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user