Skip to content

Commit

Permalink
avoid corrupting immutable TypeVar after building a DataType for them
Browse files Browse the repository at this point in the history
corrupt them before instead :)
when it's less likely someone is looking

fix #12238
fix #16301
  • Loading branch information
vtjnash committed May 12, 2016
1 parent 9906495 commit 458297b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
jl_datatype_t *dt = NULL;
JL_GC_PUSH4(&para, &super, &temp, &dt);
temp = eval(args[2], locals, lam); // field names
for(size_t i=0; i < jl_svec_len(para); i++) {
((jl_tvar_t*)jl_svecref(para,i))->bound = 0;
}
dt = jl_new_datatype((jl_sym_t*)name, jl_any_type, (jl_svec_t*)para,
(jl_svec_t*)temp, NULL,
0, args[5]==jl_true ? 1 : 0, jl_unbox_long(args[6]));
Expand Down Expand Up @@ -377,9 +380,6 @@ static jl_value_t *eval(jl_value_t *e, jl_value_t **locals, jl_lambda_info_t *la
b->value = temp;
jl_rethrow();
}
for(size_t i=0; i < jl_svec_len(para); i++) {
((jl_tvar_t*)jl_svecref(para,i))->bound = 0;
}
jl_compute_field_offsets(dt);
if (para == (jl_value_t*)jl_emptysvec && jl_is_datatype_singleton(dt)) {
dt->instance = newstruct(dt);
Expand Down
8 changes: 8 additions & 0 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4112,6 +4112,14 @@ f16090() = typeof(undefined_x16090::Tuple{Type{Int}})
undefined_x16090 = (Int,)
@test_throws TypeError f16090()

# issue #12238
type A12238{T} end
type B12238{T,S}
a::A12238{B12238{Int,S}}
end
@test B12238.types[1] === A12238{B12238{Int}}
@test A12238{B12238{Int}}.instance === B12238.types[1].instance

# issue #16315
let a = Any[]
@noinline f() = a[end]
Expand Down

0 comments on commit 458297b

Please sign in to comment.