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" {...@@ -7029,8 +7029,7 @@ test "fibonacci" {
7029 undefined behavior, which is always a compile error if the compiler knows it happened.7029 undefined behavior, which is always a compile error if the compiler knows it happened.
7030 But what would have happened if we used a signed integer?7030 But what would have happened if we used a signed integer?
7031 </p>7031 </p>
7032 {#code_begin|test_err|evaluation exceeded 1000 backwards branches#}7032 {#code_begin|syntax#}
7033 {#backend_stage1#}
7034const assert = @import("std").debug.assert;7033const assert = @import("std").debug.assert;
70357034
7036fn fibonacci(index: i32) i32 {7035fn fibonacci(index: i32) i32 {
...@@ -7045,13 +7044,22 @@ test "fibonacci" {...@@ -7045,13 +7044,22 @@ test "fibonacci" {
7045}7044}
7046 {#code_end#}7045 {#code_end#}
7047 <p>7046 <p>
7048 The compiler noticed that evaluating this function at compile-time took a long time,7047 The compiler is supposed to notice that evaluating this function at
7049 and thus emitted a compile error and gave up. If the programmer wants to increase7048 compile-time took more than 1000 branches, and thus emits an error and
7050 the budget for compile-time computation, they can use a built-in function called7049 gives up. If the programmer wants to increase the budget for compile-time
7051 {#link|@setEvalBranchQuota#} to change the default number 1000 to something else.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.
7052 </p>7059 </p>
7053 <p>7060 <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?
7055 </p>7063 </p>
7056 {#code_begin|test_err|reached unreachable#}7064 {#code_begin|test_err|reached unreachable#}
7057const assert = @import("std").debug.assert;7065const assert = @import("std").debug.assert;