authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-11-30 20:23:44-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-12-01 00:38:02-07:00
log8f079bad1f623b8da2bf327f7d8fd85cbecd1e39
tree6c6815cb514bb4045a7061b1224bb0f711d11908
parent9f9f1aadc7701e60f580591ecd987fde6232d0a6

langref: acknowledge design flaw in the self-hosted compiler

See tracking issue #13724

1 files changed, 15 insertions(+), 7 deletions(-)

doc/langref.html.in+15-7
......@@ -7029,8 +7029,7 @@ test "fibonacci" {
70297029 undefined behavior, which is always a compile error if the compiler knows it happened.
70307030 But what would have happened if we used a signed integer?
70317031 </p>
7032 {#code_begin|test_err|evaluation exceeded 1000 backwards branches#}
7033 {#backend_stage1#}
7032 {#code_begin|syntax#}
70347033const assert = @import("std").debug.assert;
70357034
70367035fn fibonacci(index: i32) i32 {
......@@ -7045,13 +7044,22 @@ test "fibonacci" {
70457044}
70467045 {#code_end#}
70477046 <p>
7048 The compiler noticed that evaluating this function at compile-time took a long time,
7049 and thus emitted a compile error and gave up. If the programmer wants to increase
7050 the budget for compile-time computation, they can use a built-in function called
7051 {#link|@setEvalBranchQuota#} to change the default number 1000 to something else.
7047 The compiler is supposed to notice that evaluating this function at
7048 compile-time took more than 1000 branches, and thus emits an error and
7049 gives up. If the programmer wants to increase the budget for compile-time
7050 computation, they can use a built-in function called
7051 {#link|@setEvalBranchQuota#} to change the default number 1000 to
7052 something else.
7053 </p>
7054 <p>
7055 However, there is a <a href="https://github.com/ziglang/zig/issues/13724">design
7056 flaw in the compiler</a> causing it to stack overflow instead of having the proper
7057 behavior here. I'm terribly sorry about that. I hope to get this resolved
7058 before the next release.
70527059 </p>
70537060 <p>
7054 What if we fix the base case, but put the wrong value in the {#syntax#}expect{#endsyntax#} line?
7061 What if we fix the base case, but put the wrong value in the
7062 {#syntax#}expect{#endsyntax#} line?
70557063 </p>
70567064 {#code_begin|test_err|reached unreachable#}
70577065const assert = @import("std").debug.assert;