Interaction between comptime var and runtime struct creation #17063
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Zig Version
0.11.0 (playground)
Steps to Reproduce and Observed Behavior
This code runs without error:
However, if you uncomment "line A", then "line B" errors. That is, the introduction of the runtime code
_ = MyStruct { .v = 5 };
changes the type ofMyStruct
.Expected Behavior
My guess as to what's going on is that this is an interaction between mutation (
comptime var
) and laziness. Mutation and laziness should never mix, so I'd expect either:MyStruct
contains ani32
at the time it is defined.comptime var
is not allowed in type definitions.Related to #7396, though so far as I've seen this isn't exactly covered by any of the other issues it cites. For example, there are no closures involved.
The text was updated successfully, but these errors were encountered: