authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-14 10:51:59-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-14 10:51:59-05:00
logc58b80203443dcbf8b737ebdaa1f17fb20c77711
treeb1e9af991951c68e1fa7042b2f75091a61c0c8cf
parenta4e32d9fb143dbfb622a5097ea4a1e4bcad03463
signaturelock-open Commit is signed but in an unrecognized format.

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

2 files changed, 0 insertions(+), 20 deletions(-)

src/ir.cpp-6
...@@ -18172,12 +18172,6 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,...@@ -18172,12 +18172,6 @@ static IrInstruction *ir_analyze_instruction_type_id(IrAnalyze *ira,
18172static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,18172static IrInstruction *ir_analyze_instruction_set_eval_branch_quota(IrAnalyze *ira,
18173 IrInstructionSetEvalBranchQuota *instruction)18173 IrInstructionSetEvalBranchQuota *instruction)
18174{18174{
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
18181 uint64_t new_quota;18175 uint64_t new_quota;
18182 if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota))18176 if (!ir_resolve_usize(ira, instruction->new_quota->child, &new_quota))
18183 return ira->codegen->invalid_instruction;18177 return ira->codegen->invalid_instruction;
test/compile_errors.zig-14
...@@ -4554,20 +4554,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {...@@ -4554,20 +4554,6 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
4554 ".tmp_source.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal",4554 ".tmp_source.zig:2:24: error: expected [2]u8 literal, found [3]u8 literal",
4555 );4555 );
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
4571 cases.add(4557 cases.add(
4572 "wrong pointer implicitly casted to pointer to @OpaqueType()",4558 "wrong pointer implicitly casted to pointer to @OpaqueType()",
4573 \\const Derp = @OpaqueType();4559 \\const Derp = @OpaqueType();