Closed
Description
I was messing around with a toy promote_rule
example and I discovered a segfault on Julia 0.5 and StackOverflow
in Julia 0.6
julia> type ModInt{n} <: Integer
k::Int
ModInt(k::Integer) = new(mod(k,n))
end
julia> Base.promote_rule{n}(::Type{ModInt{n}}, ::Type{Int}) = ModInt{n}
julia> Base.promote_rule{n}(::Type{Int}, ::Type{ModInt{n}}) = Int
Julia 0.5
julia> promote(ModInt{4}(6), 7)
Segmentation fault: 11
Julia 0.6
julia> promote(ModInt{4}(6), 7)
ERROR: StackOverflowError:
Stacktrace:
[1] promote_type(::Type{ModInt{4}}, ::Type{Int64}) at ./promotion.jl:149 (repeats 80000 times)