Skip to content

Commit

Permalink
Workaround UndefVarError: A not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Jan 11, 2020
1 parent 4c6f22a commit 8a33b9d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/context.jl
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ See also: [`canrecurse`](@ref), [`overdub`](@ref), [`recurse`](@ref), [`prehook
# to `Core.apply_type`. In the future, it would be best for Julia's compiler to better handle
# varargs calls to such functions with type arguments, or at least provide a better way to
# force specialization on the type arguments.
@inline call(::ContextUntagged, f::typeof(Core.apply_type), ::Type{A}, ::Type{B}) where {A,B} = f(A, B)
@inline call(::ContextTagged, f::typeof(Core.apply_type), ::Type{A}, ::Type{B}) where {A,B} = f(A, B)
@inline call(::ContextUntagged, f::typeof(Core.apply_type), a::Type{A}, b::Type{B}) where {A,B} = @isdefined(A) && @isdefined(B) ? f(A, B) : f(a, b)
@inline call(::ContextTagged, f::typeof(Core.apply_type), a::Type{A}, b::Type{B}) where {A,B} = @isdefined(A) && @isdefined(B) ? f(A, B) : f(a, b)

"""
```
Expand Down
8 changes: 4 additions & 4 deletions test/misctests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,10 @@ kwargtest(foobar; foo = 1, bar = 2) = nothing
@inferred(overdub(InferCtx(), eltype, rand(1)))
@inferred(overdub(InferCtx(), *, rand(1, 1), rand(1, 1)))
@inferred(overdub(InferCtx(), *, rand(Float32, 1, 1), rand(Float32, 1, 1)))
@inferred(overdub(InferCtx(), *, rand(Float32, 1, 1), rand(Float32, 1)))
@inferred(overdub(InferCtx(), rand, Float32, 1))
@inferred(overdub(InferCtx(), broadcast, +, rand(1), rand(1)))
@inferred(overdub(InferCtx(), relulayer, rand(Float64, 1, 1), rand(Float32, 1), rand(Float32, 1)))
@test_broken @inferred(overdub(InferCtx(), *, rand(Float32, 1, 1), rand(Float32, 1)))
@test_broken @inferred(overdub(InferCtx(), rand, Float32, 1))
@test_broken @inferred(overdub(InferCtx(), broadcast, +, rand(1), rand(1)))
@test_broken @inferred(overdub(InferCtx(), relulayer, rand(Float64, 1, 1), rand(Float32, 1), rand(Float32, 1)))
@inferred(overdub(InferCtx(), () -> kwargtest(42; foo = 1, bar = 2)))

println("done (took ", time() - before_time, " seconds)")
Expand Down

0 comments on commit 8a33b9d

Please sign in to comment.