commit 92c4e4f2c234816a70472250702f834a1842f4e6 (tree)
parent ab88165326abfd81c5046e8c064bd6603198ed94
Author: Veikka Tuominen <git@vexu.eu>
Date: Thu, 26 May 2022 12:42:50 +0300
Sema: `zirArrayType` does need source location
Diffstat:
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/Sema.zig b/src/Sema.zig
@@ -5814,8 +5814,10 @@ fn zirArrayType(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
defer tracy.end();
const bin_inst = sema.code.instructions.items(.data)[inst].bin;
- const len = try sema.resolveInt(block, .unneeded, bin_inst.lhs, Type.usize);
- const elem_type = try sema.resolveType(block, .unneeded, bin_inst.rhs);
+ const len_src = sema.src; // TODO better source location
+ const elem_src = sema.src; // TODO better source location
+ const len = try sema.resolveInt(block, len_src, bin_inst.lhs, Type.usize);
+ const elem_type = try sema.resolveType(block, elem_src, bin_inst.rhs);
const array_ty = try Type.array(sema.arena, len, null, elem_type, sema.mod);
return sema.addType(array_ty);
diff --git a/test/cases/compile_errors/invalid_array_elem_ty.zig b/test/cases/compile_errors/invalid_array_elem_ty.zig
@@ -0,0 +1,11 @@
+pub fn S() type {
+ return struct {};
+}
+pub export fn entry() void {
+ _ = [0]S;
+}
+
+// error
+// backend=stage2,llvm
+//
+// :4:1: error: expected type, found fn() type