Skip to content

Commit 4ecdc37

Browse files
authored
Fix typo in >= 3 arg fastmath method (#54630)
1 parent a4e793e commit 4ecdc37

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

base/fastmath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ for op in (:+, :*, :min, :max)
286286
# definitions down to avoid losing type information.
287287
# type promotion
288288
$op_fast(a::Number, b::Number, c::Number, xs::Number...) =
289-
$op_fast(promote(x,y,c,xs...)...)
289+
$op_fast(promote(a,b,c,xs...)...)
290290
# fall-back implementation that applies after promotion
291291
$op_fast(a::T, b::T, c::T, xs::T...) where {T<:Number} = (@inline; afoldl($op_fast, ($op_fast)(($op_fast)(a,b),c), xs...))
292292
end

test/fastmath.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,9 @@ end
343343
x = @fastmath maximum(Float16[1,2,3]; init = Float16(0))
344344
@test x == Float16(3)
345345
end
346+
347+
@testset "Test promotion of >=3 arg fastmath" begin
348+
# Bug caught in https://github.com/JuliaLang/julia/pull/54513#discussion_r1620553369
349+
x = @fastmath 1. + 1. + 1f0
350+
@test x == 3.0
351+
end

0 commit comments

Comments
 (0)