As I understand, this is how you initialize it currently.
```
type Animal = struct {
id: uint
};
type Dog = struct {
base: Animal,
legs: u8
};
export fn main() void = {
let dog = Dog {
base = Animal {
id = 1,
},
legs = 4,
};
};
```
but I'd expect it to work like so:
```
export fn main() void = {
let dog = Dog {
base.id = 0,
legs = 4,
};
};
```
As "base" is already user-defined, why would struct specification be
needed?
I'm not sure if this applies to your actual use case, but you can embed
a struct without giving it a field name, and its fields will appear in
the outer struct:
type Animal = struct {
id: uint,
};
type Dog = struct {
Animal,
legs: u8,
};
export fn main() void = {
let dog = Dog {
id = 1,
legs = 4,
};
};
Note that this still has the same layout semantics as a named field
would, as opposed to just copying the fields into the struct definition.
I would be open to a spec update and a harec patch that makes this work:
On Wed Jan 4, 2023 at 1:11 PM CET, Maurice Huuskes wrote:
> export fn main() void = {> let dog = Dog {> base.id = 0,> legs = 4, > };> };> ```