Skip to content

Commit 17e0bc3

Browse files
N5N3lazarusA
authored andcommitted
typeintersect: conservative typevar subtitution during finish_unionall (JuliaLang#54465)
This commit adds a nothrow path for type instantiation, which eliminates the bad `Union` elements from the result rather than returns the bottom type. close JuliaLang#54404
1 parent e8588a1 commit 17e0bc3

File tree

6 files changed

+267
-128
lines changed

6 files changed

+267
-128
lines changed

src/builtins.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1564,11 +1564,11 @@ JL_CALLABLE(jl_f_apply_type)
15641564
jl_vararg_t *vm = (jl_vararg_t*)args[0];
15651565
if (!vm->T) {
15661566
JL_NARGS(apply_type, 2, 3);
1567-
return (jl_value_t*)jl_wrap_vararg(args[1], nargs == 3 ? args[2] : NULL, 1);
1567+
return (jl_value_t*)jl_wrap_vararg(args[1], nargs == 3 ? args[2] : NULL, 1, 0);
15681568
}
15691569
else if (!vm->N) {
15701570
JL_NARGS(apply_type, 2, 2);
1571-
return (jl_value_t*)jl_wrap_vararg(vm->T, args[1], 1);
1571+
return (jl_value_t*)jl_wrap_vararg(vm->T, args[1], 1, 0);
15721572
}
15731573
}
15741574
else if (jl_is_unionall(args[0])) {
@@ -2474,7 +2474,7 @@ void jl_init_primitives(void) JL_GC_DISABLED
24742474
add_builtin("Tuple", (jl_value_t*)jl_anytuple_type);
24752475
add_builtin("TypeofVararg", (jl_value_t*)jl_vararg_type);
24762476
add_builtin("SimpleVector", (jl_value_t*)jl_simplevector_type);
2477-
add_builtin("Vararg", (jl_value_t*)jl_wrap_vararg(NULL, NULL, 0));
2477+
add_builtin("Vararg", (jl_value_t*)jl_wrap_vararg(NULL, NULL, 0, 0));
24782478

24792479
add_builtin("Module", (jl_value_t*)jl_module_type);
24802480
add_builtin("MethodTable", (jl_value_t*)jl_methtable_type);

src/gf.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ static jl_value_t *inst_varargp_in_env(jl_value_t *decl, jl_svec_t *sparams)
771771
vm = T_has_tv ? jl_type_unionall(v, T) : T;
772772
if (N_has_tv)
773773
N = NULL;
774-
vm = (jl_value_t*)jl_wrap_vararg(vm, N, 1); // this cannot throw for these inputs
774+
vm = (jl_value_t*)jl_wrap_vararg(vm, N, 1, 0); // this cannot throw for these inputs
775775
}
776776
sp++;
777777
decl = ((jl_unionall_t*)decl)->body;
@@ -1020,7 +1020,7 @@ static void jl_compilation_sig(
10201020
// avoid Vararg{Type{Type{...}}}
10211021
if (jl_is_type_type(type_i) && jl_is_type_type(jl_tparam0(type_i)))
10221022
type_i = (jl_value_t*)jl_type_type;
1023-
type_i = (jl_value_t*)jl_wrap_vararg(type_i, (jl_value_t*)NULL, 1); // this cannot throw for these inputs
1023+
type_i = (jl_value_t*)jl_wrap_vararg(type_i, (jl_value_t*)NULL, 1, 0); // this cannot throw for these inputs
10241024
}
10251025
else {
10261026
type_i = inst_varargp_in_env(decl, sparams);

0 commit comments

Comments
 (0)