authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-13 20:27:04+01:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-12-13 20:27:04+01:00
log561565fa81e4107f50b8cbdcc00ec0fa2ee4de15
tree6f3864e9dba352c570249dec6e980f921ffa871a
parentd569e37cb538d17d009f5632c25acd643d3736cb

stage1: Fix crash in can_mutate_comptime_var_state

No lazy value can mutate global state, no need to resolve them. Closes #7426

1 files changed, 22 insertions(+), 0 deletions(-)

src/stage1/analyze.cpp+22
...@@ -5749,6 +5749,28 @@ static bool can_mutate_comptime_var_state(ZigValue *value) {...@@ -5749,6 +5749,28 @@ static bool can_mutate_comptime_var_state(ZigValue *value) {
5749 assert(value != nullptr);5749 assert(value != nullptr);
5750 if (value->special == ConstValSpecialUndef)5750 if (value->special == ConstValSpecialUndef)
5751 return false;5751 return false;
5752
5753 if (value->special == ConstValSpecialLazy) {
5754 // No lazy value has side effects.
5755 // Use a switch here to get a compile error whenever a new kind of lazy
5756 // value is added.
5757 switch (value->data.x_lazy->id) {
5758 case LazyValueIdInvalid:
5759 zig_unreachable();
5760
5761 case LazyValueIdAlignOf:
5762 case LazyValueIdSizeOf:
5763 case LazyValueIdPtrType:
5764 case LazyValueIdOptType:
5765 case LazyValueIdSliceType:
5766 case LazyValueIdFnType:
5767 case LazyValueIdErrUnionType:
5768 case LazyValueIdArrayType:
5769 case LazyValueIdTypeInfoDecls:
5770 return false;
5771 }
5772 }
5773
5752 switch (value->type->id) {5774 switch (value->type->id) {
5753 case ZigTypeIdInvalid:5775 case ZigTypeIdInvalid:
5754 zig_unreachable();5776 zig_unreachable();