Commit 594f52d
committed
Prewalk the syntax tree in at-static evaluation
Post-walking the syntax tree meant the `if-else` chains were evaluated
in opposite order from how they are normally processed, and this
has consequences for things like checks on the existence of symbols:
```julia
@static if VERSION >= v"1.1" && (Sys.isfreebsd() || Sys.isdragonfly())
...
@static if Sys.freebsd()
...
end
end
```
Under normal evaluation rules, this is valid — we have previously
checked that the version is great enough for the `Sys.isfreebsd()` and
`Sys.isdragonfly()` functions to exist, so the inner case doesn't need
to check the version again.
With the post-walk evaluation order, though, the inner `if` is
evaluated first, and this threw errors as we tried to actually run
the conditional. By switching to a pre-walk order, the outer `if` will
kill the block of code on pre-v1.1 versions of Julia, and the inner
case will never be evaluated.1 parent 3ccb9e3 commit 594f52d
2 files changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
| |||
104 | 103 | | |
105 | 104 | | |
106 | 105 | | |
107 | | - | |
| 106 | + | |
108 | 107 | | |
109 | 108 | | |
110 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
19 | | - | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
| |||
0 commit comments