Skip to content

Commit 5da14d5

Browse files
committed
Fix exhaustive.jl test error
Identified in JuliaDebug/Cthulhu.jl#585
1 parent 935f4b0 commit 5da14d5

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/utils.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,15 @@ function is_func_expr(@nospecialize(ex), meth::Method)
111111
end
112112
end
113113
found && break
114+
if isexpr(whereex, :(::))
115+
typeex = whereex.args[end]
116+
if isexpr(typeex, :curly) && typeex.args[1] === :Type
117+
fname = typeex.args[2]
118+
break
119+
end
120+
end
114121
whereex = whereex.args[1]
122+
isa(whereex, Expr) || return false
115123
end
116124
end
117125
# match the function name

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ isdefined(Main, :Revise) ? Main.Revise.includet("script.jl") : include("script.j
247247
src, line = definition(String, m)
248248
@test occursin("(::Type{T})(itr) where {T<:Invert}", src)
249249
@test line == 126
250+
m = @which MyArray1{Float64, 1}(undef, 5)
251+
src, line = definition(String, m)
252+
@test occursin("(self::Type{MyArray1{T,1}})(::UndefInitializer", src)
253+
m = @which MyArray2{Float64, 1}(undef, 5)
254+
src, line = definition(String, m)
255+
@test occursin("(::Type{MyArray2{T,1}})(::UndefInitializer", src)
250256

251257
# Invalidation-insulating methods used by Revise and perhaps others
252258
d = IdDict{Union{String,Symbol},Union{Function,Vector{Function}}}()

test/script.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,17 @@ only(methods(wrongline)).line = 9999 # unclear how it happened in the wild, bu
146146
# Nested `where`s
147147
struct Parametric{N} end
148148
(::Type{P})(x::Int) where P<:Parametric{N} where N = P()
149+
150+
# `where`s that are not simply `(::Type{T})(args...) where T<:SomeSpecialType`
151+
struct MyArray1{T,N}
152+
data::T
153+
end
154+
function (self::Type{MyArray1{T,1}})(::UndefInitializer, m::Int) where {T}
155+
return nothing
156+
end
157+
struct MyArray2{T,N}
158+
data::T
159+
end
160+
function (::Type{MyArray2{T,1}})(::UndefInitializer, m::Int) where {T}
161+
return nothing
162+
end

0 commit comments

Comments
 (0)