Skip to content

Commit

Permalink
implement validation of Vararg type parameter on construction
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vtjnash committed Sep 7, 2023
1 parent 06232bb commit ca69bd6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/jltypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ca69bd6

Please sign in to comment.