Skip to content

Commit

Permalink
fix #47410, syntax error with anonfn inside elseif and short-circui…
Browse files Browse the repository at this point in the history
…t op (#47499)

(cherry picked from commit 5f256e7)
  • Loading branch information
JeffBezanson authored and KristofferC committed Dec 14, 2022
1 parent 4980870 commit e51f732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4309,6 +4309,9 @@ f(x) = yt(x)
cnd)))
(define (emit-cond cnd break-labels endl)
(let* ((cnd (if (and (pair? cnd) (eq? (car cnd) 'block))
(flatten-ex 'block cnd)
cnd))
(cnd (if (and (pair? cnd) (eq? (car cnd) 'block))
(begin (if (length> cnd 2) (compile (butlast cnd) break-labels #f #f))
(last cnd))
cnd))
Expand Down
7 changes: 7 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3297,3 +3297,10 @@ f45162(f) = f(x=1)
@test Meta.lower(@__MODULE__, :(global const x::Int)) == Expr(:error, "expected assignment after \"const\"")
@test Meta.lower(@__MODULE__, :(const global x)) == Expr(:error, "expected assignment after \"const\"")
@test Meta.lower(@__MODULE__, :(const global x::Int)) == Expr(:error, "expected assignment after \"const\"")

# issue #47410
# note `eval` is needed since this needs to be at the top level
@test eval(:(if false
elseif false || (()->true)()
42
end)) == 42

0 comments on commit e51f732

Please sign in to comment.