From ae1d71bc3f8faa53b37fdce51301477bbd4d6a1b Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Thu, 7 Sep 2023 16:08:55 +0000 Subject: [PATCH] implement validation of Vararg type parameter on construction It does not seem necessary to allow this, though it does lead to this printing issue to disallow it: julia> Tuple{1, 1, 1, 1} NTuple{4, 1} Fix #51228 --- src/builtins.c | 2 +- src/jltypes.c | 2 +- src/julia_internal.h | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/builtins.c b/src/builtins.c index d0d4b3bf1dbefa..7dd75062e7d22d 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -1324,7 +1324,7 @@ static int is_nestable_type_param(jl_value_t *t) return 0; } -int jl_valid_type_param(jl_value_t *v) +static int jl_valid_type_param(jl_value_t *v) { if (jl_is_tuple(v) || jl_is_namedtuple(v)) return is_nestable_type_param(jl_typeof(v)); diff --git a/src/jltypes.c b/src/jltypes.c index 4e566339e30149..7985174cf90c46 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2428,7 +2428,7 @@ jl_vararg_t *jl_wrap_vararg(jl_value_t *t, jl_value_t *n, int check) } } if (t) { - if (!jl_valid_type_param(t)) { + if (!jl_is_type(t) && !jl_is_typevar(t)) { jl_type_error_rt("Vararg", "type", (jl_value_t*)jl_type_type, t); } t = normalize_unionalls(t); diff --git a/src/julia_internal.h b/src/julia_internal.h index b2ba10d7bd084a..37eb00db5a1d9a 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -655,8 +655,6 @@ int get_root_reference(rle_reference *rr, jl_method_t *m, size_t i) JL_NOTSAFEPO jl_value_t *lookup_root(jl_method_t *m, uint64_t key, int index) JL_NOTSAFEPOINT; int nroots_with_key(jl_method_t *m, uint64_t key) JL_NOTSAFEPOINT; -int jl_valid_type_param(jl_value_t *v); - JL_DLLEXPORT jl_value_t *jl_apply_2va(jl_value_t *f, jl_value_t **args, uint32_t nargs); void JL_NORETURN jl_method_error(jl_function_t *f, jl_value_t **args, size_t na, size_t world);