diff --git a/src/jltypes.c b/src/jltypes.c index 444923f6005692..024d0be74e659b 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -1593,19 +1593,20 @@ static unsigned typekey_hash(jl_typename_t *tn, jl_value_t **key, size_t n, int int failed = nofail; for (j = 0; j < n; j++) { jl_value_t *p = key[j]; + size_t repeats = 1; if (jl_is_vararg(p)) { jl_vararg_t *vm = (jl_vararg_t*)p; - if (!nofail && vm->N) - return 0; - // 0x064eeaab is just a randomly chosen constant - hash = bitmix(vm->N ? type_hash(vm->N, &failed) : 0x064eeaab, hash); - if (failed && !nofail) - return 0; + if (vm->N && jl_is_long(vm->N)) + repeats = jl_unbox_long(vm->N); + else + hash = bitmix(0x064eeaab, hash); // 0x064eeaab is just a randomly chosen constant p = vm->T ? vm->T : (jl_value_t*)jl_any_type; } - hash = bitmix(type_hash(p, &failed), hash); + unsigned hashp = type_hash(p, &failed); if (failed && !nofail) return 0; + while (repeats--) + hash = bitmix(hashp, hash); } hash = bitmix(~tn->hash, hash); return hash ? hash : 1; diff --git a/test/tuple.jl b/test/tuple.jl index 71770b6a553c2d..8ff311928b6b83 100644 --- a/test/tuple.jl +++ b/test/tuple.jl @@ -796,3 +796,8 @@ namedtup = (;a=1, b=2, c=3) @test_throws ErrorException("Tuple field type cannot be Union{}") Tuple{Vararg{Union{},1}} @test Tuple{} <: Tuple{Vararg{Union{},N}} where N @test !(Tuple{} >: Tuple{Vararg{Union{},N}} where N) + +@test Val{Tuple{T,T,T} where T} === Val{Tuple{Vararg{T,3}} where T} +@test Val{Tuple{Vararg{T,4}} where T} === Val{Tuple{T,T,T,T} where T} +@test Val{Tuple{Int64, Vararg{Int32,N}} where N} === Val{Tuple{Int64, Vararg{Int32}}} +@test Val{Tuple{Int32, Vararg{Int64}}} === Val{Tuple{Int32, Vararg{Int64,N}} where N}