authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2021-03-23 13:48:52+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-03-23 11:56:06-07:00
log830143905e5e89e6dcf8a0831790072ee88eb2f9
treedad00bddd5e428a9dbf679aac667b318aa770142
parent7194baed66c57484e5369ab023ee9a030a7478c5

Sema: use correct LazySrcLoc for resolvePeerTypes


1 files changed, 7 insertions(+), 7 deletions(-)

src/Sema.zig+7-7
......@@ -588,7 +588,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde
588588 const ptr_val = ptr.castTag(.constant).?.val;
589589 const inferred_alloc = ptr_val.castTag(.inferred_alloc).?;
590590 const peer_inst_list = inferred_alloc.data.stored_inst_list.items;
591 const final_elem_ty = try sema.resolvePeerTypes(block, peer_inst_list);
591 const final_elem_ty = try sema.resolvePeerTypes(block, ty_src, peer_inst_list);
592592 const var_is_mut = switch (ptr.ty.tag()) {
593593 .inferred_alloc_const => false,
594594 .inferred_alloc_mut => true,
......@@ -899,7 +899,7 @@ fn analyzeBlockBody(
899899 // Need to set the type and emit the Block instruction. This allows machine code generation
900900 // to emit a jump instruction to after the block when it encounters the break.
901901 try parent_block.instructions.append(sema.gpa, &merges.block_inst.base);
902 const resolved_ty = try sema.resolvePeerTypes(parent_block, merges.results.items);
902 const resolved_ty = try sema.resolvePeerTypes(parent_block, .todo, merges.results.items);
903903 merges.block_inst.base.ty = resolved_ty;
904904 merges.block_inst.body = .{
905905 .instructions = try sema.arena.dupe(*Inst, child_block.instructions.items),
......@@ -2347,7 +2347,7 @@ fn zirBitwise(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
23472347 const rhs = try sema.resolveInst(bin_inst.rhs);
23482348
23492349 const instructions = &[_]*Inst{ lhs, rhs };
2350 const resolved_type = try sema.resolvePeerTypes(block, instructions);
2350 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
23512351 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs.src);
23522352 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs.src);
23532353
......@@ -2433,7 +2433,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
24332433 const rhs = try sema.resolveInst(extra.rhs);
24342434
24352435 const instructions = &[_]*Inst{ lhs, rhs };
2436 const resolved_type = try sema.resolvePeerTypes(block, instructions);
2436 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
24372437 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
24382438 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);
24392439
......@@ -2694,7 +2694,7 @@ fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
26942694 inst_list[i] = try sema.resolveInst(arg_ref);
26952695 }
26962696
2697 const result_type = try sema.resolvePeerTypes(block, inst_list);
2697 const result_type = try sema.resolvePeerTypes(block, src, inst_list);
26982698 return sema.mod.constType(sema.arena, src, result_type);
26992699}
27002700
......@@ -4028,7 +4028,7 @@ fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst
40284028 }
40294029}
40304030
4031fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, instructions: []*Inst) !Type {
4031fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, instructions: []*Inst) !Type {
40324032 if (instructions.len == 0)
40334033 return Type.initTag(.noreturn);
40344034
......@@ -4079,7 +4079,7 @@ fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, instructions: []*Inst) !Ty
40794079 }
40804080
40814081 // TODO error notes pointing out each type
4082 return sema.mod.fail(&block.base, candidate.src, "incompatible types: '{}' and '{}'", .{ chosen.ty, candidate.ty });
4082 return sema.mod.fail(&block.base, src, "incompatible types: '{}' and '{}'", .{ chosen.ty, candidate.ty });
40834083 }
40844084
40854085 return chosen.ty;