| author | |
| committer | |
| log | 5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63 |
| tree | a4bffd48c7c31b64af53425464e0c0c048156abf |
| parent | 01081ce5a59f4e2e57a9ff6e5885269ed3014279 |
| parent | d532c21d890e1aa22cd4c57d6a3f749890256254 |
| signature |
stage2: misc fixes on the way to `std.debug.dumpCurrentStackTrace`7 files changed, 44 insertions(+), 12 deletions(-)
lib/std/debug.zig-1| ... | ... | @@ -1630,7 +1630,6 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo { |
| 1630 | 1630 | .symbol_name = nosuspend di.getSymbolName(address) orelse "???", |
| 1631 | 1631 | .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) { |
| 1632 | 1632 | error.MissingDebugInfo, error.InvalidDebugInfo => "???", |
| 1633 | else => return err, | |
| 1634 | 1633 | }, |
| 1635 | 1634 | .line_info = nosuspend di.getLineNumberInfo(compile_unit.*, address) catch |err| switch (err) { |
| 1636 | 1635 | error.MissingDebugInfo, error.InvalidDebugInfo => null, |
lib/std/dwarf.zig+1-1| ... | ... | @@ -822,7 +822,7 @@ pub const DwarfInfo = struct { |
| 822 | 822 | // in the list itself. |
| 823 | 823 | // If no starting value is specified use zero. |
| 824 | 824 | var base_address = compile_unit.die.getAttrAddr(AT.low_pc) catch |err| switch (err) { |
| 825 | error.MissingDebugInfo => 0, | |
| 825 | error.MissingDebugInfo => @as(u64, 0), // TODO https://github.com/ziglang/zig/issues/11135 | |
| 826 | 826 | else => return err, |
| 827 | 827 | }; |
| 828 | 828 |
src/AstGen.zig+2-3| ... | ... | @@ -1035,9 +1035,8 @@ fn nosuspendExpr( |
| 1035 | 1035 | }); |
| 1036 | 1036 | } |
| 1037 | 1037 | gz.nosuspend_node = node; |
| 1038 | const result = try expr(gz, scope, rl, body_node); | |
| 1039 | gz.nosuspend_node = 0; | |
| 1040 | return rvalue(gz, rl, result, node); | |
| 1038 | defer gz.nosuspend_node = 0; | |
| 1039 | return expr(gz, scope, rl, body_node); | |
| 1041 | 1040 | } |
| 1042 | 1041 | |
| 1043 | 1042 | fn suspendExpr( |
src/Sema.zig+9-2| ... | ... | @@ -6972,7 +6972,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError |
| 6972 | 6972 | return sema.failWithOwnedErrorMsg(block, msg); |
| 6973 | 6973 | } |
| 6974 | 6974 | |
| 6975 | if (special_prong == .@"else") { | |
| 6975 | if (special_prong == .@"else" and seen_errors.count() == operand_ty.errorSetNames().len) { | |
| 6976 | 6976 | return sema.fail( |
| 6977 | 6977 | block, |
| 6978 | 6978 | special_prong_src, |
| ... | ... | @@ -16692,6 +16692,13 @@ fn coerceInMemoryAllowedErrorSets( |
| 16692 | 16692 | else => unreachable, |
| 16693 | 16693 | } |
| 16694 | 16694 | |
| 16695 | if (dst_ies.func == sema.owner_func) { | |
| 16696 | // We are trying to coerce an error set to the current function's | |
| 16697 | // inferred error set. | |
| 16698 | try dst_ies.addErrorSet(sema.gpa, src_ty); | |
| 16699 | return .ok; | |
| 16700 | } | |
| 16701 | ||
| 16695 | 16702 | try sema.resolveInferredErrorSet(block, dest_src, dst_payload.data); |
| 16696 | 16703 | // isAnyError might have changed from a false negative to a true positive after resolution. |
| 16697 | 16704 | if (dest_ty.isAnyError()) { |
| ... | ... | @@ -18910,7 +18917,7 @@ fn resolvePeerTypes( |
| 18910 | 18917 | } |
| 18911 | 18918 | |
| 18912 | 18919 | const chosen_set_ty = err_set_ty orelse chosen_ty.errorUnionSet(); |
| 18913 | const candidate_set_ty = chosen_ty.errorUnionSet(); | |
| 18920 | const candidate_set_ty = candidate_ty.errorUnionSet(); | |
| 18914 | 18921 | |
| 18915 | 18922 | if (.ok == try sema.coerceInMemoryAllowedErrorSets(block, chosen_set_ty, candidate_set_ty, src, src)) { |
| 18916 | 18923 | err_set_ty = chosen_set_ty; |
src/codegen/llvm.zig+8-1| ... | ... | @@ -5347,7 +5347,14 @@ pub const FuncGen = struct { |
| 5347 | 5347 | if (self.liveness.isUnused(inst)) return null; |
| 5348 | 5348 | |
| 5349 | 5349 | const llvm_i32 = self.context.intType(32); |
| 5350 | const llvm_fn = self.getIntrinsic("llvm.frameaddress", &.{llvm_i32}); | |
| 5350 | const llvm_fn_name = "llvm.frameaddress.p0i8"; | |
| 5351 | const llvm_fn = self.dg.object.llvm_module.getNamedFunction(llvm_fn_name) orelse blk: { | |
| 5352 | const llvm_p0i8 = self.context.intType(8).pointerType(0); | |
| 5353 | const param_types = [_]*const llvm.Type{llvm_i32}; | |
| 5354 | const fn_type = llvm.functionType(llvm_p0i8, &param_types, param_types.len, .False); | |
| 5355 | break :blk self.dg.object.llvm_module.addFunction(llvm_fn_name, fn_type); | |
| 5356 | }; | |
| 5357 | ||
| 5351 | 5358 | const params = [_]*const llvm.Value{llvm_i32.constNull()}; |
| 5352 | 5359 | const ptr_val = self.builder.buildCall(llvm_fn, &params, params.len, .Fast, .Auto, ""); |
| 5353 | 5360 | const llvm_usize = try self.dg.llvmType(Type.usize); |
test/behavior/error.zig+23| ... | ... | @@ -626,3 +626,26 @@ test "inferred error set equality" { |
| 626 | 626 | try expect(BarError == BarError); |
| 627 | 627 | try expect(BazError == BazError); |
| 628 | 628 | } |
| 629 | ||
| 630 | test "peer type resolution of two different error unions" { | |
| 631 | const a: error{B}!void = {}; | |
| 632 | const b: error{A}!void = {}; | |
| 633 | var cond = true; | |
| 634 | const err = if (cond) a else b; | |
| 635 | try err; | |
| 636 | } | |
| 637 | ||
| 638 | test "coerce error set to the current inferred error set" { | |
| 639 | const S = struct { | |
| 640 | fn foo() !void { | |
| 641 | var a = false; | |
| 642 | if (a) { | |
| 643 | const b: error{A}!void = error.A; | |
| 644 | return b; | |
| 645 | } | |
| 646 | const b = error.A; | |
| 647 | return b; | |
| 648 | } | |
| 649 | }; | |
| 650 | S.foo() catch {}; | |
| 651 | } |
test/behavior/switch.zig+1-4| ... | ... | @@ -610,14 +610,11 @@ test "switch on pointer type" { |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | test "switch on error set with single else" { |
| 613 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 614 | ||
| 615 | 613 | const S = struct { |
| 616 | 614 | fn doTheTest() !void { |
| 617 | 615 | var some: error{Foo} = error.Foo; |
| 618 | 616 | try expect(switch (some) { |
| 619 | else => |a| blk: { | |
| 620 | a catch {}; | |
| 617 | else => blk: { | |
| 621 | 618 | break :blk true; |
| 622 | 619 | }, |
| 623 | 620 | }); |