Skip to content

Commit 36169a9

Browse files
simeonschaubKristofferC
authored andcommitted
fix #39705: lowering of Expr(:||) (#39709)
(cherry picked from commit 0858864)
1 parent b6c224b commit 36169a9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/julia-syntax.scm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1927,7 +1927,10 @@
19271927
(stmts (if blk? (cdr (butlast test)) '()))
19281928
(test (if blk? (last test) test)))
19291929
(if (and (pair? test) (memq (car test) '(&& |\|\||)))
1930-
(let ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test))))))
1930+
(let* ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test)))))
1931+
(clauses (if (null? (cdr clauses))
1932+
(if (eq? (car clauses) '&&) '(true) '(false))
1933+
clauses)))
19311934
`(if ,(if blk?
19321935
`(block ,@(map expand-forms stmts) ,clauses)
19331936
clauses)

test/cartesian.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,7 @@ end
405405

406406
@test @inferred(intersect(I, J)) == CartesianIndices((2:3, 4:5))
407407
end
408+
409+
# issue #39705
410+
f39705() = Base.Cartesian.@nany 0 _ -> true
411+
@test f39705() === false

test/syntax.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2700,3 +2700,7 @@ end
27002700

27012701
@test eval(Expr(:string, "a", Expr(:string, "b", "c"))) == "abc"
27022702
@test eval(Expr(:string, "a", Expr(:string, "b", Expr(:string, "c")))) == "abc"
2703+
2704+
# issue #39705
2705+
@eval f39705(x) = $(Expr(:||)) && x
2706+
@test f39705(1) === false

0 commit comments

Comments
 (0)