Skip to content

Commit 0858864

Browse files
authored
fix #39705: lowering of Expr(:||) (#39709)
1 parent 55d7571 commit 0858864

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
@@ -1928,7 +1928,10 @@
19281928
(stmts (if blk? (cdr (butlast test)) '()))
19291929
(test (if blk? (last test) test)))
19301930
(if (and (pair? test) (memq (car test) '(&& |\|\||)))
1931-
(let ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test))))))
1931+
(let* ((clauses `(,(car test) ,@(map expand-forms (cdr (flatten-ex (car test) test)))))
1932+
(clauses (if (null? (cdr clauses))
1933+
(if (eq? (car clauses) '&&) '(true) '(false))
1934+
clauses)))
19321935
`(if ,(if blk?
19331936
`(block ,@(map expand-forms stmts) ,clauses)
19341937
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
@@ -2707,3 +2707,7 @@ end == 4
27072707
@test ncalls_in_lowered(:(.!(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1
27082708
@test ncalls_in_lowered(:((.!)(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1
27092709
end
2710+
2711+
# issue #39705
2712+
@eval f39705(x) = $(Expr(:||)) && x
2713+
@test f39705(1) === false

0 commit comments

Comments
 (0)