Nemocas/AbstractAlgebra.jl

Loading this package breacks `show(Union{}[])`

thofma opened this issue · 4 comments

thofma commented
julia> show(Union{}[])
ERROR: UndefVarError: `U` not defined
Stacktrace:
 [1] extract_gens(B::Vector{Union{}})
   @ AbstractAlgebra.Generic ~/repositories/bla/packages/AbstractAlgebra/rGnXn/src/generic/Ideal.jl:1287
 [2] show(io::Base.TTY, B::Vector{Union{}})
   @ AbstractAlgebra.Generic ~/repositories/bla/packages/AbstractAlgebra/rGnXn/src/generic/Ideal.jl:243
 [3] show(x::Vector{Union{}})
   @ Base ./show.jl:456
 [4] top-level scope
   @ REPL[21]:1

This method should just be renamed (the one in generic/Ideal.jl:243).

fieker commented
thofma commented

This is the same reason and discussion as in #1466. Adding a method f(x::Vector{T}) where T <: OurType and f comes from Base is bad and leads to unintended errors. They should all be purged.

Changing it to Vector{lmnode} does not work, since lmnode is parametrized.

This fixes it:

diff --git a/src/generic/Ideal.jl b/src/generic/Ideal.jl
index 8a9e41e09..835ed5489 100644
--- a/src/generic/Ideal.jl
+++ b/src/generic/Ideal.jl
@@ -238,7 +238,7 @@ function show_inner(io::IO, n::lmnode)
 end
 
 # print a vector of nodes
-function show(io::IO, B::Vector{<:lmnode})
+function show(io::IO, B::Vector{lmnode{U, V, N}}) where {U, V, N}
    if print_node_level[] == 0
       BB = extract_gens(B)
       print(io, "[")

but I guess we should also add a test?

thofma commented

Ah, yes, lmnode is not abstract, so one can work around it like this, thanks.