mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 00:08:56 +00:00
Sema: fix source location for untyped array init with result type
Resolves: #17923
This commit is contained in:
parent
ee47643b6e
commit
4504e03a18
@ -4400,7 +4400,7 @@ fn zirValidateArrayInitTy(
|
||||
const mod = sema.mod;
|
||||
const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
|
||||
const src = inst_data.src();
|
||||
const ty_src: LazySrcLoc = .{ .node_offset_init_ty = inst_data.src_node };
|
||||
const ty_src: LazySrcLoc = if (is_result_ty) src else .{ .node_offset_init_ty = inst_data.src_node };
|
||||
const extra = sema.code.extraData(Zir.Inst.ArrayInit, inst_data.payload_index).data;
|
||||
const ty = sema.resolveType(block, ty_src, extra.ty) catch |err| switch (err) {
|
||||
// It's okay for the type to be unknown: this will result in an anonymous array init.
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
fn dummy(_: u32) void {}
|
||||
|
||||
export fn foo() void {
|
||||
dummy(.{ 1, 2 });
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :4:12: error: type 'u32' does not support array initialization syntax
|
||||
Loading…
x
Reference in New Issue
Block a user