Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/fastmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ for op in (:+, :*, :min, :max)
# definitions down to avoid losing type information.
# type promotion
$op_fast(a::Number, b::Number, c::Number, xs::Number...) =
$op_fast(promote(x,y,c,xs...)...)
$op_fast(promote(a,b,c,xs...)...)
# fall-back implementation that applies after promotion
$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...))
end
Expand Down
6 changes: 6 additions & 0 deletions test/fastmath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,9 @@ end
x = @fastmath maximum(Float16[1,2,3]; init = Float16(0))
@test x == Float16(3)
end

@testset "Test promotion of >=3 arg fastmath" begin
# Bug caught in https://github.com/JuliaLang/julia/pull/54513#discussion_r1620553369
x = @fastmath 1. + 1. + 1f0
@test x == 3.0
end