aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-12-15 15:07:49 -0500
committerGitHub <noreply@github.com>2020-12-15 15:07:49 -0500
commitb3c1ced2c37a8265314833fd74a105ca788db927 (patch)
tree49c7b8ef8bcd8325bf11ab427f0ef9c91fcaa5fd /src/stage1/analyze.cpp
parentb3f4802aa0436346d423db5a3f04fdd804b1d364 (diff)
parentbbfa3550a02e82df91f5e2fafeab564906ae943c (diff)
downloadzig-b3c1ced2c37a8265314833fd74a105ca788db927.tar.gz
zig-b3c1ced2c37a8265314833fd74a105ca788db927.zip
Merge pull request #7431 from LemonBoy/fix-7426
stage1: Fix crash in can_mutate_comptime_var_state
Diffstat (limited to 'src/stage1/analyze.cpp')
-rw-r--r--src/stage1/analyze.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp
index 3f95456c3f..40a294e8d8 100644
--- a/src/stage1/analyze.cpp
+++ b/src/stage1/analyze.cpp
@@ -5729,6 +5729,28 @@ static bool can_mutate_comptime_var_state(ZigValue *value) {
assert(value != nullptr);
if (value->special == ConstValSpecialUndef)
return false;
+
+ if (value->special == ConstValSpecialLazy) {
+ // No lazy value has side effects.
+ // Use a switch here to get a compile error whenever a new kind of lazy
+ // value is added.
+ switch (value->data.x_lazy->id) {
+ case LazyValueIdInvalid:
+ zig_unreachable();
+
+ case LazyValueIdAlignOf:
+ case LazyValueIdSizeOf:
+ case LazyValueIdPtrType:
+ case LazyValueIdOptType:
+ case LazyValueIdSliceType:
+ case LazyValueIdFnType:
+ case LazyValueIdErrUnionType:
+ case LazyValueIdArrayType:
+ case LazyValueIdTypeInfoDecls:
+ return false;
+ }
+ }
+
switch (value->type->id) {
case ZigTypeIdInvalid:
zig_unreachable();