| ... | ... | @@ -7048,8 +7048,10 @@ test "foo" { |
| 7048 | 7048 | <li>All variables are {#syntax#}comptime{#endsyntax#} variables.</li> |
| 7049 | 7049 | <li>All {#syntax#}if{#endsyntax#}, {#syntax#}while{#endsyntax#}, {#syntax#}for{#endsyntax#}, and {#syntax#}switch{#endsyntax#} |
| 7050 | 7050 | expressions are evaluated at compile-time, or emit a compile error if this is not possible.</li> |
| 7051 | | <li>All function calls cause the compiler to interpret the function at compile-time, emitting a |
| 7052 | | compile error if the function tries to do something that has global run-time side effects.</li> |
| 7051 | <li>All {#syntax#}return{#endsyntax#} and {#syntax#}try{#endsyntax#} expressions are invalid (unless the function itself is called at compile-time).</li> |
| 7052 | <li>All code with runtime side effects or depending on runtime values emits a compile error.</li> |
| 7053 | <li>All function calls cause the compiler to interpret the function at compile-time, emitting a |
| 7054 | compile error if the function tries to do something that has global runtime side effects.</li> |
| 7053 | 7055 | </ul> |
| 7054 | 7056 | <p> |
| 7055 | 7057 | This means that a programmer can create a function which is called both at compile-time and run-time, with |
| ... | ... | @@ -7071,9 +7073,7 @@ test "fibonacci" { |
| 7071 | 7073 | try expect(fibonacci(7) == 13); |
| 7072 | 7074 | |
| 7073 | 7075 | // test fibonacci at compile-time |
| 7074 | | comptime { |
| 7075 | | try expect(fibonacci(7) == 13); |
| 7076 | | } |
| 7076 | try comptime expect(fibonacci(7) == 13); |
| 7077 | 7077 | } |
| 7078 | 7078 | {#code_end#} |
| 7079 | 7079 | <p> |
| ... | ... | @@ -7088,9 +7088,7 @@ fn fibonacci(index: u32) u32 { |
| 7088 | 7088 | } |
| 7089 | 7089 | |
| 7090 | 7090 | test "fibonacci" { |
| 7091 | | comptime { |
| 7092 | | try expect(fibonacci(7) == 13); |
| 7093 | | } |
| 7091 | try comptime expect(fibonacci(7) == 13); |
| 7094 | 7092 | } |
| 7095 | 7093 | {#code_end#} |
| 7096 | 7094 | <p> |
| ... | ... | @@ -7111,9 +7109,7 @@ fn fibonacci(index: i32) i32 { |
| 7111 | 7109 | } |
| 7112 | 7110 | |
| 7113 | 7111 | test "fibonacci" { |
| 7114 | | comptime { |
| 7115 | | try assert(fibonacci(7) == 13); |
| 7116 | | } |
| 7112 | try comptime assert(fibonacci(7) == 13); |
| 7117 | 7113 | } |
| 7118 | 7114 | {#code_end#} |
| 7119 | 7115 | <p> |
| ... | ... | @@ -7143,9 +7139,7 @@ fn fibonacci(index: i32) i32 { |
| 7143 | 7139 | } |
| 7144 | 7140 | |
| 7145 | 7141 | test "fibonacci" { |
| 7146 | | comptime { |
| 7147 | | try assert(fibonacci(7) == 99999); |
| 7148 | | } |
| 7142 | try comptime assert(fibonacci(7) == 99999); |
| 7149 | 7143 | } |
| 7150 | 7144 | {#code_end#} |
| 7151 | 7145 | |