mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
a9d63d729e
commit
bbf1ba458e
@ -921,8 +921,8 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, styp string, str_fn_name stri
|
|||||||
funcprefix += 'isnil(it.${c_name(field.name)})'
|
funcprefix += 'isnil(it.${c_name(field.name)})'
|
||||||
funcprefix += ' ? _SLIT("nil") : '
|
funcprefix += ' ? _SLIT("nil") : '
|
||||||
// struct, floats and ints have a special case through the _str function
|
// struct, floats and ints have a special case through the _str function
|
||||||
if sym.kind !in [.struct_, .alias, .enum_, .interface_] && !field.typ.is_int_valptr()
|
if sym.kind !in [.struct_, .alias, .enum_, .sum_type, .map, .interface_]
|
||||||
&& !field.typ.is_float_valptr() {
|
&& !field.typ.is_int_valptr() && !field.typ.is_float_valptr() {
|
||||||
funcprefix += '*'
|
funcprefix += '*'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
vlib/v/gen/c/testdata/ref_sumtype_as_struct_field.out
vendored
Normal file
3
vlib/v/gen/c/testdata/ref_sumtype_as_struct_field.out
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
SumTypePtr{
|
||||||
|
ptr: &nil
|
||||||
|
}
|
14
vlib/v/gen/c/testdata/ref_sumtype_as_struct_field.vv
vendored
Normal file
14
vlib/v/gen/c/testdata/ref_sumtype_as_struct_field.vv
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
struct S1 {}
|
||||||
|
|
||||||
|
struct S2 {}
|
||||||
|
|
||||||
|
type T1 = S1 | S2
|
||||||
|
|
||||||
|
struct SumTypePtr {
|
||||||
|
ptr &T1 = unsafe { nil }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
ptr := SumTypePtr{}
|
||||||
|
println(ptr)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user