Skip to content

Commit 89dc2ab

Browse files
committed
fix #44735, assert typeintersect arguments on Julia level
1 parent 8e12f70 commit 89dc2ab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/subtype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,8 @@ static int subtype(jl_value_t *x, jl_value_t *y, jl_stenv_t *e, int param)
12581258
}
12591259
if (jl_is_unionall(y))
12601260
return subtype_unionall(x, (jl_unionall_t*)y, e, 1, param);
1261-
assert(!jl_is_vararg(x) && !jl_is_vararg(y));
1261+
else if (jl_is_vararg(x) || jl_is_vararg(y))
1262+
jl_errorf("invalid subtyping with Vararg");
12621263
if (jl_is_datatype(x) && jl_is_datatype(y)) {
12631264
if (x == y) return 1;
12641265
if (y == (jl_value_t*)jl_any_type) return 1;

test/subtype.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,3 +1976,7 @@ end
19761976
@testintersect(Tuple{Type{Pair{_A, S} where S<:AbstractArray{<:_A, 2}}, Dict} where _A,
19771977
Tuple{Type{Pair{_A, S} where S<:AbstractArray{<:_A, 2}} where _A, Union{Array, Pair}},
19781978
Bottom)
1979+
1980+
# https://github.com/JuliaLang/julia/issues/44735
1981+
@test_throws ErrorException("invalid subtyping with Vararg") typeintersect(Vararg{Int}, Int)
1982+
@test_throws ErrorException("invalid subtyping with Vararg") typeintersect(Int, Vararg{Int})

0 commit comments

Comments
 (0)