Julia: UnionAll clashing with type parameter for function

Created on 14 Sep 2019  路  3Comments  路  Source: JuliaLang/julia

On Julia master:

julia> struct Pullback{S, T}
               t::T
             end

julia> function Base.show(io::IO, ::Type{<:Pullback{S}}) where S 
                S
              end

julia> P = Pullback{Tuple{Type{T}}, T} where T
Error showing value of type UnionAll:
ERROR: UndefVarError: S not defined
Stacktrace:
 [1] show(::IOContext{REPL.Terminals.TTYTerminal}, ::Type{
SYSTEM (REPL): showing an error caused an error
ERROR: UndefVarError: S not defined
Stacktrace:
 [1] show(::IOContext{REPL.Terminals.TTYTerminal}, ::Type{
SYSTEM (REPL): caught exception of type UndefVarError while trying to handle a nested exception; giving up

cc: @vchuravy, major props for helping me track this down

This code is part of Zygote.jl so cc: @MikeInnes

Most helpful comment

I'm wondering if we should try using the fallback printing for the exception if it throws an error again.

All 3 comments

The initial error isn't a bug. The type parameter is undefined. Obviously the subsequent errors are incorrect.

https://github.com/FluxML/Zygote.jl/issues/134 should maybe be reopened.

Overloading show on type and messing up will make showing errors fail, since they use that.

I'm wondering if we should try using the fallback printing for the exception if it throws an error again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpsanders picture dpsanders  路  3Comments

ararslan picture ararslan  路  3Comments

m-j-w picture m-j-w  路  3Comments

i-apellaniz picture i-apellaniz  路  3Comments

tkoolen picture tkoolen  路  3Comments