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...@@ -588,7 +588,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Inde
588 const ptr_val = ptr.castTag(.constant).?.val;588 const ptr_val = ptr.castTag(.constant).?.val;
589 const inferred_alloc = ptr_val.castTag(.inferred_alloc).?;589 const inferred_alloc = ptr_val.castTag(.inferred_alloc).?;
590 const peer_inst_list = inferred_alloc.data.stored_inst_list.items;590 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);
592 const var_is_mut = switch (ptr.ty.tag()) {592 const var_is_mut = switch (ptr.ty.tag()) {
593 .inferred_alloc_const => false,593 .inferred_alloc_const => false,
594 .inferred_alloc_mut => true,594 .inferred_alloc_mut => true,
...@@ -899,7 +899,7 @@ fn analyzeBlockBody(...@@ -899,7 +899,7 @@ fn analyzeBlockBody(
899 // Need to set the type and emit the Block instruction. This allows machine code generation899 // Need to set the type and emit the Block instruction. This allows machine code generation
900 // to emit a jump instruction to after the block when it encounters the break.900 // to emit a jump instruction to after the block when it encounters the break.
901 try parent_block.instructions.append(sema.gpa, &merges.block_inst.base);901 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);
903 merges.block_inst.base.ty = resolved_ty;903 merges.block_inst.base.ty = resolved_ty;
904 merges.block_inst.body = .{904 merges.block_inst.body = .{
905 .instructions = try sema.arena.dupe(*Inst, child_block.instructions.items),905 .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...@@ -2347,7 +2347,7 @@ fn zirBitwise(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerError
2347 const rhs = try sema.resolveInst(bin_inst.rhs);2347 const rhs = try sema.resolveInst(bin_inst.rhs);
23482348
2349 const instructions = &[_]*Inst{ lhs, rhs };2349 const instructions = &[_]*Inst{ lhs, rhs };
2350 const resolved_type = try sema.resolvePeerTypes(block, instructions);2350 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
2351 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs.src);2351 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs.src);
2352 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs.src);2352 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...@@ -2433,7 +2433,7 @@ fn zirArithmetic(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
2433 const rhs = try sema.resolveInst(extra.rhs);2433 const rhs = try sema.resolveInst(extra.rhs);
24342434
2435 const instructions = &[_]*Inst{ lhs, rhs };2435 const instructions = &[_]*Inst{ lhs, rhs };
2436 const resolved_type = try sema.resolvePeerTypes(block, instructions);2436 const resolved_type = try sema.resolvePeerTypes(block, src, instructions);
2437 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);2437 const casted_lhs = try sema.coerce(block, resolved_type, lhs, lhs_src);
2438 const casted_rhs = try sema.coerce(block, resolved_type, rhs, rhs_src);2438 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...@@ -2694,7 +2694,7 @@ fn zirTypeofPeer(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerEr
2694 inst_list[i] = try sema.resolveInst(arg_ref);2694 inst_list[i] = try sema.resolveInst(arg_ref);
2695 }2695 }
26962696
2697 const result_type = try sema.resolvePeerTypes(block, inst_list);2697 const result_type = try sema.resolvePeerTypes(block, src, inst_list);
2698 return sema.mod.constType(sema.arena, src, result_type);2698 return sema.mod.constType(sema.arena, src, result_type);
2699}2699}
27002700
...@@ -4028,7 +4028,7 @@ fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst...@@ -4028,7 +4028,7 @@ fn wrapErrorUnion(sema: *Sema, block: *Scope.Block, dest_type: Type, inst: *Inst
4028 }4028 }
4029}4029}
40304030
4031fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, instructions: []*Inst) !Type {4031fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, src: LazySrcLoc, instructions: []*Inst) !Type {
4032 if (instructions.len == 0)4032 if (instructions.len == 0)
4033 return Type.initTag(.noreturn);4033 return Type.initTag(.noreturn);
40344034
...@@ -4079,7 +4079,7 @@ fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, instructions: []*Inst) !Ty...@@ -4079,7 +4079,7 @@ fn resolvePeerTypes(sema: *Sema, block: *Scope.Block, instructions: []*Inst) !Ty
4079 }4079 }
40804080
4081 // TODO error notes pointing out each type4081 // 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 });
4083 }4083 }
40844084
4085 return chosen.ty;4085 return chosen.ty;