diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index 892a090d65e07..322ff25ff52cb 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -1928,7 +1928,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) diff --git a/test/cartesian.jl b/test/cartesian.jl index 32c3e1fb0a4e6..af0bc466e3d04 100644 --- a/test/cartesian.jl +++ b/test/cartesian.jl @@ -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 diff --git a/test/syntax.jl b/test/syntax.jl index 5a7b256ef3010..25c86d3689cbb 100644 --- a/test/syntax.jl +++ b/test/syntax.jl @@ -2707,3 +2707,7 @@ end == 4 @test ncalls_in_lowered(:(.!(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1 @test ncalls_in_lowered(:((.!)(1 .< A .< 2)), GlobalRef(Base, :materialize)) == 1 end + +# issue #39705 +@eval f39705(x) = $(Expr(:||)) && x +@test f39705(1) === false