Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax error with anonfn inside elseif and short-circuit op #47499

Merged
merged 1 commit into from
Nov 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix #47410, syntax error with anonfn inside elseif and short-circui…
…t op
  • Loading branch information
JeffBezanson committed Nov 15, 2022
commit f3637eb3b5e3a7060f651c3cb372c732e7c186a0
3 changes: 3 additions & 0 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
@@ -4404,6 +4404,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))
7 changes: 7 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
@@ -3422,3 +3422,10 @@ end
# issue #46251
@test begin; global value = 1; (value, value += 1) end == (1, 2)
@test begin; global value = 1; "($(value), $(value += 1))" end == "(1, 2)"

# 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