| author | |
| committer | |
| log | 8c4727f9ab61e4c99ab2a00f5751f9b11d274fbe |
| tree | 84177f2c8532ab9ee8ca47bcecb22d93b3238ccf |
| parent | 3e084d8de352927dad182f99aeb3f166b348c192 |
3 files changed, 31 insertions(+), 8 deletions(-)
src/Module.zig-8| ... | @@ -3519,14 +3519,6 @@ pub fn deinit(mod: *Module) void { | ... | @@ -3519,14 +3519,6 @@ pub fn deinit(mod: *Module) void { |
| 3519 | pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { | 3519 | pub fn destroyDecl(mod: *Module, decl_index: Decl.Index) void { |
| 3520 | const gpa = mod.gpa; | 3520 | const gpa = mod.gpa; |
| 3521 | { | 3521 | { |
| 3522 | if (mod.failed_decls.contains(decl_index)) { | ||
| 3523 | blk: { | ||
| 3524 | const errs = mod.comp.getAllErrorsAlloc() catch break :blk; | ||
| 3525 | for (errs.list) |err| Compilation.AllErrors.Message.renderToStdErr(err, .no_color); | ||
| 3526 | } | ||
| 3527 | // TODO restore test case triggering this panic | ||
| 3528 | @panic("Zig compiler bug: attempted to destroy declaration with an attached error"); | ||
| 3529 | } | ||
| 3530 | const decl = mod.declPtr(decl_index); | 3522 | const decl = mod.declPtr(decl_index); |
| 3531 | log.debug("destroy {*} ({s})", .{ decl, decl.name }); | 3523 | log.debug("destroy {*} ({s})", .{ decl, decl.name }); |
| 3532 | _ = mod.test_functions.swapRemove(decl_index); | 3524 | _ = mod.test_functions.swapRemove(decl_index); |
src/Sema.zig+1| ... | @@ -7174,6 +7174,7 @@ fn instantiateGenericCall( | ... | @@ -7174,6 +7174,7 @@ fn instantiateGenericCall( |
| 7174 | return err; | 7174 | return err; |
| 7175 | }, | 7175 | }, |
| 7176 | else => { | 7176 | else => { |
| 7177 | assert(mod.monomorphed_funcs.remove(new_module_func)); | ||
| 7177 | { | 7178 | { |
| 7178 | errdefer new_decl_arena.deinit(); | 7179 | errdefer new_decl_arena.deinit(); |
| 7179 | try new_decl.finalizeNewArena(&new_decl_arena); | 7180 | try new_decl.finalizeNewArena(&new_decl_arena); |
test/cases/compile_errors/generic_function_instantiation_inherits_parent_branch_quota.zig created+30| ... | @@ -0,0 +1,30 @@ | ||
| 1 | pub export fn entry1() void { | ||
| 2 | @setEvalBranchQuota(1001); | ||
| 3 | // Return type evaluation should inherit both the | ||
| 4 | // parent's branch quota and count meaning | ||
| 5 | // at least 2002 backwards branches are required. | ||
| 6 | comptime var i = 0; | ||
| 7 | inline while (i < 1000) : (i += 1) {} | ||
| 8 | _ = simple(10); | ||
| 9 | } | ||
| 10 | pub export fn entry2() void { | ||
| 11 | @setEvalBranchQuota(2001); | ||
| 12 | comptime var i = 0; | ||
| 13 | inline while (i < 1000) : (i += 1) {} | ||
| 14 | _ = simple(10); | ||
| 15 | } | ||
| 16 | fn simple(comptime n: usize) Type(n) { | ||
| 17 | return n; | ||
| 18 | } | ||
| 19 | fn Type(comptime n: usize) type { | ||
| 20 | if (n <= 1) return usize; | ||
| 21 | return Type(n - 1); | ||
| 22 | } | ||
| 23 | |||
| 24 | // error | ||
| 25 | // backend=stage2 | ||
| 26 | // target=native | ||
| 27 | // | ||
| 28 | // :21:16: error: evaluation exceeded 1001 backwards branches | ||
| 29 | // :21:16: note: use @setEvalBranchQuota() to raise the branch limit from 1001 | ||
| 30 | // :16:34: note: called from here | ||