Skip to content

Commit 95c1718

Browse files
KristofferCKristofferC
andauthored
Test: avoid identifying .. calls as broadcasting calls (#59771)
Introduced in d934b03 Causes e.g: https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/6353098_vs_7522b24/TokenIterators.primary.log cc @omus Co-authored-by: KristofferC <[email protected]>
1 parent 5ddcea7 commit 95c1718

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/Test/src/Test.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,9 @@ function _escape_call(@nospecialize ex)
631631
# Update broadcast comparison calls to the function call syntax
632632
# (e.g. `1 .== 1` becomes `(==).(1, 1)`)
633633
func_str = string(ex.args[1])
634-
escaped_func = if first(func_str) == '.'
634+
# Check if this is a broadcast operator (starts with '.' and has more characters that aren't '.')
635+
is_broadcast = length(func_str) >= 2 && first(func_str) == '.' && any(c -> c != '.', func_str[2:end])
636+
escaped_func = if is_broadcast
635637
esc(Expr(:., Symbol(func_str[2:end])))
636638
else
637639
esc(ex.args[1])

stdlib/Test/test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ import Logging: Debug, Info, Warn, with_logger
2424
@test isapprox(1, 1; [(:atol, 0)]...)
2525
@test isapprox(1, 2; atol)
2626
@test isapprox(1, 3; a.atol)
27+
# Test custom .. operator (not a broadcast operator)
28+
..(x, y) = x == y
29+
@test 'a' .. 'a'
30+
@test !('a' .. 'b')
2731
end
2832
@testset "@test with skip/broken kwargs" begin
2933
# Make sure the local variables can be used in conditions
@@ -1950,6 +1954,8 @@ end
19501954
@test _escape_call(:(Main.f.(x, y))) == (; func=:(Broadcast.BroadcastFunction($(esc(:(Main.f))))), args, kwargs, quoted_func=QuoteNode(Expr(:., :(Main.f))))
19511955
@test _escape_call(:(x .== y)) == (; func=esc(:(.==)), args, kwargs, quoted_func=:(:.==))
19521956
@test _escape_call(:((==).(x, y))) == (; func=Expr(:., esc(:(==))), args, kwargs, quoted_func=QuoteNode(Expr(:., :(==))))
1957+
# Test that .. operator is not treated as a broadcast operator
1958+
@test _escape_call(:(x .. y)) == (; func=esc(:(..)), args, kwargs, quoted_func=:(:..))
19531959
end
19541960
end
19551961

0 commit comments

Comments
 (0)