v
v copied to clipboard
Embedded structs break default sum type values if they are followed by other fields with default values
Describe the bug
struct Papa {
fam_name string
}
pub struct Child {
Papa
pub mut:
activity Activity = Fun.roll
// some string // Adding a field in-between makes it work.
age u8 = 2
// activity Activity = Fun.roll // Placing the field with the sumtype after works aswell.
}
type Activity = Fun | Other
pub enum Fun {
run
roll
jump
}
pub struct Other {}
// Same struct without embedding just works.
pub struct Human {
fam_name string
pub mut:
activity Activity = Fun.roll
age u8 = 2
}
fn main() {
c := Child{}
println(c.activity)
h := Human{}
println(h.activity)
}
unknown sum type value
Activity(roll)
Expected Behavior
Default sumtype values work with embedded struts in every position.
Current Behavior
Described in example above.
Reproduction Steps
It was kinda lucky to isolate the behavior. I hope the example above describes the actual problem.
Possible Solution
No response
Additional Information/Context
No response
V version
0.3.3
Environment details (OS name and version, etc.)
linux, arch