diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-07-06 12:29:16 +0300 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-07-07 10:50:06 +0300 |
| commit | b5ac2b4330b84799060609ce0f22eda266ad171b (patch) | |
| tree | 8a6e8401eefd602691e2b6d3686757a051513fb3 /src/AstGen.zig | |
| parent | 27ee4141592c7a9d77a2d73f5fa6a3c6262ac7fc (diff) | |
| download | zig-b5ac2b4330b84799060609ce0f22eda266ad171b.tar.gz zig-b5ac2b4330b84799060609ce0f22eda266ad171b.zip | |
Sema: improve array source location
Diffstat (limited to 'src/AstGen.zig')
| -rw-r--r-- | src/AstGen.zig | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/AstGen.zig b/src/AstGen.zig index 33526524d8..a92723b068 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -1320,7 +1320,10 @@ fn arrayInitExpr( const len_inst = try gz.addInt(array_init.ast.elements.len); const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); if (array_type.ast.sentinel == 0) { - const array_type_inst = try gz.addBin(.array_type, len_inst, elem_type); + const array_type_inst = try gz.addPlNode(.array_type, array_init.ast.type_expr, Zir.Inst.Bin{ + .lhs = len_inst, + .rhs = elem_type, + }); break :inst .{ .array = array_type_inst, .elem = elem_type, @@ -1553,7 +1556,10 @@ fn structInitExpr( if (is_inferred_array_len) { const elem_type = try typeExpr(gz, scope, array_type.ast.elem_type); const array_type_inst = if (array_type.ast.sentinel == 0) blk: { - break :blk try gz.addBin(.array_type, .zero_usize, elem_type); + break :blk try gz.addPlNode(.array_type, struct_init.ast.type_expr, Zir.Inst.Bin{ + .lhs = .zero_usize, + .rhs = elem_type, + }); } else blk: { const sentinel = try comptimeExpr(gz, scope, .{ .ty = elem_type }, array_type.ast.sentinel); break :blk try gz.addPlNode( @@ -3203,7 +3209,10 @@ fn arrayType(gz: *GenZir, scope: *Scope, rl: ResultLoc, node: Ast.Node.Index) !Z const len = try expr(gz, scope, .{ .coerced_ty = .usize_type }, len_node); const elem_type = try typeExpr(gz, scope, node_datas[node].rhs); - const result = try gz.addBin(.array_type, len, elem_type); + const result = try gz.addPlNode(.array_type, node, Zir.Inst.Bin{ + .lhs = len, + .rhs = elem_type, + }); return rvalue(gz, rl, result, node); } |
