diff options
| author | LemonBoy <thatlemon@gmail.com> | 2020-11-11 10:11:25 +0100 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2020-11-11 13:53:24 +0200 |
| commit | f0b1b74d214169a72cf5ae28d88637f20100bcad (patch) | |
| tree | ad32cf812fc0c682df365e35bcaa3cb9e0a4b046 /src/stage1/ir.cpp | |
| parent | 8b9195282e99427964119431b6f4e535eeb4d9ba (diff) | |
| download | zig-f0b1b74d214169a72cf5ae28d88637f20100bcad.tar.gz zig-f0b1b74d214169a72cf5ae28d88637f20100bcad.zip | |
stage1: Avoid resolving type entry in [0]T
The logic was already there but this rule was only applied in some
places, apply it in the remaining code paths.
Closes #7058
Diffstat (limited to 'src/stage1/ir.cpp')
| -rw-r--r-- | src/stage1/ir.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index 91fb81c24a..a984664cf8 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -32970,8 +32970,13 @@ static Error ir_resolve_lazy_raw(AstNode *source_node, ZigValue *val) { break; } - if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) - return err; + // Avoid resolving the type if the total length is zero. + // Matches the logic in get_array_type and in the lazy alignment + // resolution routine. + if (lazy_array_type->length + (lazy_array_type->sentinel != nullptr) != 0) { + if ((err = type_resolve(ira->codegen, elem_type, ResolveStatusSizeKnown))) + return err; + } ZigValue *sentinel_val = nullptr; if (lazy_array_type->sentinel != nullptr) { |
