diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-10-24 17:30:47 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-10-27 01:31:18 +0300 |
| commit | 4ac8ec4c5c80f6eca0ac7d7955c5486ef55ce042 (patch) | |
| tree | 2c3c82f5531e65b74d34b003a8048956a04b873c /src | |
| parent | 4fc944dde813638410850515b0d1b156e5b6e920 (diff) | |
| download | zig-4ac8ec4c5c80f6eca0ac7d7955c5486ef55ce042.tar.gz zig-4ac8ec4c5c80f6eca0ac7d7955c5486ef55ce042.zip | |
AstGen: fix `ref`ing inferred allocs
Closes #13285
Diffstat (limited to 'src')
| -rw-r--r-- | src/AstGen.zig | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index 07a972eaab..48e6a480f3 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -9709,7 +9709,7 @@ fn rvalue( const result_index = refToIndex(result) orelse return gz.addUnTok(.ref, result, src_token); const zir_tags = gz.astgen.instructions.items(.tag); - if (zir_tags[result_index].isParam()) + if (zir_tags[result_index].isParam() or astgen.isInferred(result)) return gz.addUnTok(.ref, result, src_token); const gop = try astgen.ref_table.getOrPut(astgen.gpa, result_index); if (!gop.found_existing) { @@ -12196,6 +12196,13 @@ fn isInferred(astgen: *AstGen, ref: Zir.Inst.Ref) bool { .alloc_inferred_comptime_mut, => true, + .extended => { + const zir_data = astgen.instructions.items(.data); + if (zir_data[inst].extended.opcode != .alloc) return false; + const small = @bitCast(Zir.Inst.AllocExtended.Small, zir_data[inst].extended.small); + return !small.has_type; + }, + else => false, }; } |
