| ... | @@ -191,3 +191,31 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) -> usize { | ... | @@ -191,3 +191,31 @@ fn testTryToTrickEvalWithRuntimeIf(b: bool) -> usize { |
| 191 | return i; | 191 | return i; |
| 192 | } | 192 | } |
| 193 | } | 193 | } |
| | 194 | |
| | 195 | fn max(comptime T: type, a: T, b: T) -> T { |
| | 196 | if (T == bool) { |
| | 197 | return a || b; |
| | 198 | } else if (a > b) { |
| | 199 | return a; |
| | 200 | } else { |
| | 201 | return b; |
| | 202 | } |
| | 203 | } |
| | 204 | fn letsTryToCompareBools(a: bool, b: bool) -> bool { |
| | 205 | max(bool, a, b) |
| | 206 | } |
| | 207 | fn inlinedBlockAndRuntimeBlockPhi() { |
| | 208 | @setFnTest(this); |
| | 209 | |
| | 210 | assert(letsTryToCompareBools(true, true)); |
| | 211 | assert(letsTryToCompareBools(true, false)); |
| | 212 | assert(letsTryToCompareBools(false, true)); |
| | 213 | assert(!letsTryToCompareBools(false, false)); |
| | 214 | |
| | 215 | comptime { |
| | 216 | assert(letsTryToCompareBools(true, true)); |
| | 217 | assert(letsTryToCompareBools(true, false)); |
| | 218 | assert(letsTryToCompareBools(false, true)); |
| | 219 | assert(!letsTryToCompareBools(false, false)); |
| | 220 | } |
| | 221 | } |