Skip to content

Commit fed1e23

Browse files
JeffBezansonararslan
authored andcommitted
fix #22842, dispatch confusion with Type{T} vs. typeof(T) (#23831)
(cherry picked from commit f4619d0)
1 parent dab2df2 commit fed1e23

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/jltypes.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,13 @@ static int typekey_eq(jl_datatype_t *tt, jl_value_t **key, size_t n)
588588
}
589589
for(j=0; j < n; j++) {
590590
jl_value_t *kj = key[j], *tj = jl_svecref(tt->parameters,j);
591-
if (tj != kj && !jl_types_equal(tj, kj))
592-
return 0;
591+
if (tj != kj) {
592+
// require exact same Type{T}. see e.g. issue #22842
593+
if (jl_is_type_type(tj) || jl_is_type_type(kj))
594+
return 0;
595+
if (!jl_types_equal(tj, kj))
596+
return 0;
597+
}
593598
}
594599
return 1;
595600
}

test/core.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,12 @@ let
907907
@test_throws MethodError foor(StridedArray)
908908
end
909909

910+
# issue #22842
911+
f22842(x::UnionAll) = UnionAll
912+
f22842(x::DataType) = length(x.parameters)
913+
@test f22842(Tuple{Vararg{Int64,N} where N}) == 1
914+
@test f22842(Tuple{Vararg{Int64,N}} where N) === UnionAll
915+
910916
# issue #1153
911917
mutable struct SI{m, s, kg}
912918
value::AbstractFloat

0 commit comments

Comments
 (0)