Skip to content

Commit 1a1f50d

Browse files
authored
Merge pull request #138 from JuliaDebug/teh/union
Don't try to call `nameof` on Unions
2 parents 3ded02f + 37d4b46 commit 1a1f50d

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/construct.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ function prepare_call(@nospecialize(f), allargs; enter_generated = false)
206206
# Can happen for thunks created by generated functions
207207
if isa(f, Core.Builtin) || isa(f, Core.IntrinsicFunction)
208208
return nothing
209-
elseif any(x -> isa(x, Type) &&
210-
(x <: Vararg || (typeof(x) in (UnionAll, DataType) && nameof(x) == :Vararg)), allargs)
209+
elseif any(is_vararg_type, allargs)
211210
return nothing # https://github.com/JuliaLang/julia/issues/30995
212211
end
213212
argtypes = Tuple{map(_Typeof,allargs)...}

src/utils.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ end
131131

132132
is_leaf(frame::Frame) = frame.callee === nothing
133133

134+
function is_vararg_type(x)
135+
if isa(x, Type)
136+
x <: Vararg && return true
137+
if isa(x, UnionAll)
138+
x = Base.unwrap_unionall(x)
139+
end
140+
return isa(x, DataType) && nameof(x) == :Vararg
141+
end
142+
return false
143+
end
144+
134145
## Location info
135146

136147
function lineoffset(framecode::FrameCode)

test/interpret.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,4 +379,8 @@ end
379379
buf = IOBuffer()
380380
me = Base.MethodError(method_c1,(1, 1, ""))
381381
@test (@interpret Base.show_method_candidates(buf, me)) == nothing
382+
383+
varargidentity(x) = x
384+
x = Union{Array{UInt8,N},Array{Int8,N}} where N
385+
@test isa(JuliaInterpreter.prepare_call(varargidentity, [varargidentity, x])[1], JuliaInterpreter.FrameCode)
382386
end

0 commit comments

Comments
 (0)