JuliaLabs / Cassette.jl

Overdub Your Julia Code
Other
371 stars 35 forks source link

No-op overdub fails for `Base.typename` with UnionAll #130

Open mbauman opened 5 years ago

mbauman commented 5 years ago
julia> Cassette.@context Noop
Cassette.Context{nametype(Noop),M,T,P,B,H} where H<:Union{Cassette.DisableHooks, Nothing} where B<:Union{Nothing, IdDict{Module,Dict{Symbol,Cassette.BindingMeta}}} where P<:Cassette.AbstractPass where T<:Union{Nothing, Cassette.Tag} where M

julia> struct T2{T}
           x::T
       end

julia> Cassette.@overdub(Noop(), Base.typename(T2))
ERROR: type DataType has no field body
Stacktrace:
 [1] getproperty at ./Base.jl:15 [inlined]
 [2] call at /home/mbauman/.julia/dev/Cassette/src/context.jl:447 [inlined]
 [3] fallback at /home/mbauman/.julia/dev/Cassette/src/context.jl:445 [inlined]
 [4] overdub at /home/mbauman/.julia/dev/Cassette/src/context.jl:271 [inlined]
 [5] typename at ./essentials.jl:296 [inlined]
 [6] overdub(::Cassette.Context{nametype(Noop),Nothing,Nothing,getfield(Cassette, Symbol("##PassType#399")),Nothing,Nothing}, ::typeof(Base.typename), ::Type{T2}) at /home/mbauman/.julia/dev/Cassette/src/overdub.jl:0
 [7] typename at ./essentials.jl:296 [inlined]
 [8] overdub(::Cassette.Context{nametype(Noop),Nothing,Nothing,getfield(Cassette, Symbol("##PassType#399")),Nothing,Nothing}, ::typeof(Base.typename), ::Type{T2}) at /home/mbauman/.julia/dev/Cassette/src/overdub.jl:0
 [9] recurse(::Cassette.Context{nametype(Noop),Nothing,Nothing,getfield(Cassette, Symbol("##PassType#399")),Nothing,Nothing}, ::getfield(Main, Symbol("##44#45"))) at /home/mbauman/.julia/dev/Cassette/src/overdub.jl:666
 [10] top-level scope at REPL[48]:1
vchuravy commented 5 years ago

Hm this is weird, looking at it with Cthulhu it almost seems like we stashed a DataType in the args, but expected a Union...

KristofferC commented 4 years ago

Happens here to: https://github.com/maleadt/BasePkgEvalReports/blob/0bb12607c245153c8e7215788e580d43d7d2d51a/pkgeval-9bd498d_vs_2e6715c/logs/SimpleMock/1.4.0-DEV-082f446f52.log (when testing SimpleMock.jl).

bundasht commented 4 years ago

@KristofferC Hey, any updates on this issue? Thanks.

kmsquire commented 4 years ago

I also ran into #142 (which was closed as a duplicate of this issue) when trying to use SimpleMock in one of my projects.

ArbitRandomUser commented 2 years ago

encountered this issue with Luxor ; while using sethue

boiled down to the same error when using supertype on RGBA in Colors

julia> Cassette.overdub(ctx(),Colors.parse,RGBA,"red")
ERROR: type DataType has no field var
Stacktrace:
  [1] getproperty
    @ ./Base.jl:37 [inlined]
  [2] call
    @ ~/.julia/packages/Cassette/1lyEM/src/context.jl:456 [inlined]
  [3] fallback
    @ ~/.julia/packages/Cassette/1lyEM/src/context.jl:454 [inlined]
  [4] overdub
    @ ~/.julia/packages/Cassette/1lyEM/src/context.jl:279 [inlined]
  [5] overdub
    @ ./operators.jl:50 [inlined]
  [6] overdub(::Cassette.Context{nametype(ctx), Nothing, Nothing, Cassette.var"##PassType#276", Nothing, Nothing}, ::typeof(supertype), ::Type{RGBA})
    @ Cassette ~/.julia/packages/Cassette/1lyEM/src/overdub.jl:0
  [7] overdub
    @ ./operators.jl:50 [inlined]
  [8] overdub(::Cassette.Context{nametype(ctx), Nothing, Nothing, Cassette.var"##PassType#276", Nothing, Nothing}, ::typeof(supertype), ::Type{RGBA})
    @ Cassette ~/.julia/packages/Cassette/1lyEM/src/overdub.jl:0