Skip to content

Commit c58b802

Browse files
committed
remove the "top of the comptime stack" compile error
It's still best practice to put `@setEvalBranchQuota` at the top of the comptime stack, but as Jimmi notes in #1949, when a function can be called at comptime and also can be the top of the comptime stack, this compile error is fundamentally unsound. So now it's gone. closes #1949
1 parent a4e32d9 commit c58b802

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

src/ir.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18172,12 +18172,6 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
1817218172
static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
1817318173
IrInstructionSetEvalBranchQuota *instruction)
1817418174
{
18175-
if (ira->new_irb.exec->parent_exec != nullptr && !ira->new_irb.exec->is_generic_instantiation) {
18176-
ir_add_error(ira, &instruction->base,
18177-
buf_sprintf("@setEvalBranchQuota must be called from the top of the comptime stack"));
18178-
return ira->codegen->invalid_instruction;
18179-
}
18180-
1818118175
uint64_t new_quota;
1818218176
if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota))
1818318177
return ira->codegen->invalid_instruction;

test/compile_errors.zig

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,20 +4554,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
45544554
".tmp_source.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal",
45554555
);
45564556

4557-
cases.add(
4558-
"@setEvalBranchQuota in non-root comptime execution context",
4559-
\\comptime {
4560-
\\ foo();
4561-
\\}
4562-
\\fn foo() void {
4563-
\\ @setEvalBranchQuota(1001);
4564-
\\}
4565-
,
4566-
".tmp_source.zig:5:5: error: @setEvalBranchQuota must be called from the top of the comptime stack",
4567-
".tmp_source.zig:2:8: note: called from here",
4568-
".tmp_source.zig:1:10: note: called from here",
4569-
);
4570-
45714557
cases.add(
45724558
"wrong pointer implicitly casted to pointer to @OpaqueType()",
45734559
\\const Derp = @OpaqueType();

0 commit comments

Comments
 (0)