mirror of
https://github.com/vlang/v.git
synced 2025-09-17 11:26:17 -04:00
This commit is contained in:
parent
5e78eef08a
commit
4a7f8cc139
@ -6963,7 +6963,7 @@ fn (mut g Gen) write_types(symbols []&ast.TypeSymbol) {
|
||||
if sym.info.fields.len > 0 {
|
||||
g.writeln('\t// pointers to common sumtype fields')
|
||||
for field in sym.info.fields {
|
||||
g.type_definitions.writeln('\t${g.styp(field.typ.ref())} ${c_name(field.name)};')
|
||||
g.type_definitions.writeln('\t${g.styp(field.typ)}* ${c_name(field.name)};')
|
||||
}
|
||||
}
|
||||
g.type_definitions.writeln('};')
|
||||
|
@ -0,0 +1,30 @@
|
||||
struct Value {
|
||||
x int
|
||||
}
|
||||
|
||||
struct BValue {
|
||||
v ?Value
|
||||
}
|
||||
|
||||
struct Word {
|
||||
BValue
|
||||
}
|
||||
|
||||
struct Long {
|
||||
BValue
|
||||
}
|
||||
|
||||
struct Variadic {
|
||||
BValue
|
||||
}
|
||||
|
||||
type Param = Word | Long | Variadic
|
||||
|
||||
fn test_sumtype_with_embedded_struct_of_option_field() {
|
||||
a := [Param(Word{}), Long{}, Variadic{}]
|
||||
dump(a)
|
||||
f := a[0]
|
||||
v := f.v
|
||||
dump(v)
|
||||
assert v == none
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user