Skip to content

Commit

Permalink
Restrict zero function types
Browse files Browse the repository at this point in the history
Base only provides `zero(::Type{T}) where T<:Number`, not `zero(::Type{T}) where T`, and our method results in StackOverflows when called with `Any` when it should return an error. See JuliaData/DataFrames.jl#1251
  • Loading branch information
cjprybol authored Oct 12, 2017
1 parent f54c091 commit 4111551
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nulls.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ for f in (:(!), :(+), :(-), :(Base.identity), :(Base.zero),
@eval $(f)(d::Null) = null
end

Base.zero(::Type{Union{T, Null}}) where {T} = zero(T)
Base.zero(::Type{Union{T, Null}}) where {T <: Number} = zero(T)

# Binary operators/functions
for f in (:(+), :(-), :(*), :(/), :(^),
Expand Down

0 comments on commit 4111551

Please sign in to comment.