File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -13,13 +13,21 @@ such as a `ccall` to a non-existent function.
13
13
"""
14
14
macro static (ex)
15
15
if isa (ex, Expr)
16
- if ex. head === :if || ex. head === :&& || ex. head === :||
16
+ @label loop
17
+ hd = ex. head
18
+ if hd ∈ (:if , :elseif , :&& , :|| )
17
19
cond = eval (__module__, ex. args[1 ])
18
- if xor (cond, ex . head === :|| )
20
+ if xor (cond, hd === :|| )
19
21
return esc (ex. args[2 ])
20
22
elseif length (ex. args) == 3
21
- return esc (ex. args[3 ])
22
- elseif ex. head === :if
23
+ br = ex. args[3 ]
24
+ if br isa Expr && br. head === :elseif
25
+ ex = br
26
+ @goto loop
27
+ else
28
+ return esc (ex. args[3 ])
29
+ end
30
+ elseif hd ∈ (:if , :elseif )
23
31
return nothing
24
32
else
25
33
return cond
Original file line number Diff line number Diff line change 29
29
@test (@static false && 1 ) === false
30
30
@test (@static true || 1 ) === true
31
31
@test (@static false || 1 ) === 1
32
+ @test (@static if false 1 elseif true 2 end ) === 2
33
+ @test (@static if false 1 elseif false 2 end ) === nothing
34
+ @test (@static if false 1 elseif false 2 else 3 end ) === 3
35
+ @test (@static if false 1 elseif false 2 elseif true && false 3 else 4 end ) === 4
36
+ @test (@static if false 1 elseif false 2 elseif true && false 3 end ) === nothing
32
37
end
33
38
34
39
if Sys. iswindows ()
You can’t perform that action at this time.
0 commit comments