diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-12-13 20:27:04 +0100 |
|---|---|---|
| committer | LemonBoy <thatlemon@gmail.com> | 2020-12-13 20:27:04 +0100 |
| commit | 561565fa81e4107f50b8cbdcc00ec0fa2ee4de15 (patch) | |
| tree | 6f3864e9dba352c570249dec6e980f921ffa871a /src/stage1 | |
| parent | d569e37cb538d17d009f5632c25acd643d3736cb (diff) | |
| download | zig-561565fa81e4107f50b8cbdcc00ec0fa2ee4de15.tar.gz zig-561565fa81e4107f50b8cbdcc00ec0fa2ee4de15.zip | |
stage1: Fix crash in can_mutate_comptime_var_state
No lazy value can mutate global state, no need to resolve them.
Closes #7426
Diffstat (limited to 'src/stage1')
| -rw-r--r-- | src/stage1/analyze.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index ed0a033592..35405518eb 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -5749,6 +5749,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(); |
