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
On Mon, Dec 18, 2023 at 11:37:55PM -0800, Tommy Hofmann wrote:
```
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.
Not sure:
julia> Union{} <: AbstractAlgebra.Generic.lmnode
true
julia> Union{} <: Integer
true
"our" function is a show functions for vectors of "our" types. If this
is banned, then we probably should not do any functions for vectors of
any kind, the Union{} will always match....
A possibility would be to change from Vector{<:lmnode} to Vector{lmnode}?
…
--
Reply to this email directly or view it on GitHub:
#1530
You are receiving this because you are subscribed to this thread.
Message ID: ***@***.***>
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.
fingolfin commented
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.