Skip to content

Commit

Permalink
fix #39705: lowering of Expr(:||) (#39709)
Browse files Browse the repository at this point in the history
(cherry picked from commit 0858864)
  • Loading branch information
simeonschaub authored and staticfloat committed Dec 22, 2022
1 parent 81687f3 commit 42f568e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,10 @@
(stmts (if blk? (cdr (butlast test)) '()))
(test (if blk? (last test) test)))
(if (and (pair? test) (memq (car test) '(&& |\|\||)))
(let ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test))))))
(let* ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test)))))
(clauses (if (null? (cdr clauses))
(if (eq? (car clauses) '&&) '(true) '(false))
clauses)))
`(if ,(if blk?
`(block ,@(map expand-forms stmts) ,clauses)
clauses)
Expand Down
4 changes: 4 additions & 0 deletions test/cartesian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,7 @@ end

@test @inferred(intersect(I, J)) == CartesianIndices((2:3, 4:5))
end

# issue #39705
f39705() = Base.Cartesian.@nany 0 _ -> true
@test f39705() === false
4 changes: 4 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2700,3 +2700,7 @@ end

@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc"
@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"

# issue #39705
@eval f39705(x) = $(Expr(:||)) && x
@test f39705(1) === false

0 comments on commit 42f568e

Please sign in to comment.