Skip to content

Commit 5f256e7

Browse files
authored
fix #47410, syntax error with anonfn inside elseif and short-circuit op (#47499)
1 parent ee0f3fc commit 5f256e7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/julia-syntax.scm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,6 +4404,9 @@ f(x) = yt(x)
44044404
cnd)))
44054405
(define (emit-cond cnd break-labels endl)
44064406
(let* ((cnd (if (and (pair? cnd) (eq? (car cnd) 'block))
4407+
(flatten-ex 'block cnd)
4408+
cnd))
4409+
(cnd (if (and (pair? cnd) (eq? (car cnd) 'block))
44074410
(begin (if (length> cnd 2) (compile (butlast cnd) break-labels #f #f))
44084411
(last cnd))
44094412
cnd))

test/syntax.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3422,3 +3422,10 @@ end
34223422
# issue #46251
34233423
@test begin; global value = 1; (value, value += 1) end == (1, 2)
34243424
@test begin; global value = 1; "($(value), $(value += 1))" end == "(1, 2)"
3425+
3426+
# issue #47410
3427+
# note `eval` is needed since this needs to be at the top level
3428+
@test eval(:(if false
3429+
elseif false || (()->true)()
3430+
42
3431+
end)) == 42

0 commit comments

Comments
 (0)