| ... | @@ -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#} | | |
| 7034 | const assert = @import("std").debug.assert; | 7033 | const assert = @import("std").debug.assert; |
| 7035 | | 7034 | |
| 7036 | fn fibonacci(index: i32) i32 { | 7035 | fn 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 increase | 7048 | 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 called | 7049 | 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#} |
| 7057 | const assert = @import("std").debug.assert; | 7065 | const assert = @import("std").debug.assert; |