Skip to content

Commit

Permalink
alternate fix for #29936 that handles more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Mar 14, 2019
1 parent 2d6e183 commit 1b1c7cb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ static int type_parameter_recursively_external(jl_value_t *p0) JL_NOTSAFEPOINT
return 0;
if (module_in_worklist(p->name->module))
return 0;
if (jl_unwrap_unionall(p->name->wrapper) != (jl_value_t*)p) {
if (p->name->wrapper != (jl_value_t*)p0) {
if (!type_recursively_external(p))
return 0;
}
Expand Down Expand Up @@ -327,11 +327,8 @@ static void jl_serialize_datatype(jl_serializer_state *s, jl_datatype_t *dt) JL_

write_uint8(s->s, TAG_DATATYPE);
write_uint8(s->s, tag);
if (tag == 6) {
jl_serialize_value(s, dt->name);
return;
}
if (tag == 7) {
if (tag == 6 || tag == 7) {
// for tag==6, copy its typevars in case there are references to them elsewhere
jl_serialize_value(s, dt->name);
jl_serialize_value(s, dt->parameters);
return;
Expand Down Expand Up @@ -745,7 +742,7 @@ static void jl_serialize_value_(jl_serializer_state *s, jl_value_t *v, int as_li
else if (jl_is_unionall(v)) {
write_uint8(s->s, TAG_UNIONALL);
jl_datatype_t *d = (jl_datatype_t*)jl_unwrap_unionall(v);
if (jl_is_datatype(d) && jl_unwrap_unionall(d->name->wrapper) == (jl_value_t*)d &&
if (jl_is_datatype(d) && d->name->wrapper == v &&
!module_in_worklist(d->name->module)) {
write_uint8(s->s, 1);
jl_serialize_value(s, d->name->module);
Expand Down Expand Up @@ -1335,13 +1332,8 @@ static jl_value_t *jl_deserialize_datatype(jl_serializer_state *s, int pos, jl_v
if (tag == 6 || tag == 7) {
jl_typename_t *name = (jl_typename_t*)jl_deserialize_value(s, NULL);
jl_value_t *dtv = name->wrapper;
if (tag == 7) {
jl_svec_t *parameters = (jl_svec_t*)jl_deserialize_value(s, NULL);
dtv = jl_apply_type(dtv, jl_svec_data(parameters), jl_svec_len(parameters));
}
else {
dtv = jl_unwrap_unionall(dtv);
}
jl_svec_t *parameters = (jl_svec_t*)jl_deserialize_value(s, NULL);
dtv = jl_apply_type(dtv, jl_svec_data(parameters), jl_svec_len(parameters));
backref_list.items[pos] = dtv;
return dtv;
}
Expand Down
5 changes: 5 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ try
const x28297 = Result(missing)
const d29936a = UnionAll(Dict.var, UnionAll(Dict.body.var, Dict.body.body))
const d29936b = UnionAll(Dict.body.var, UnionAll(Dict.var, Dict.body.body))
# issue #28998
const x28998 = [missing, 2, missing, 6, missing,
Expand Down Expand Up @@ -187,6 +189,9 @@ try

@test Foo.x28297.result === missing

@test Foo.d29936a === Dict
@test Foo.d29936b === Dict{K,V} where {V,K}

@test Foo.x28998[end] == 6
end

Expand Down

0 comments on commit 1b1c7cb

Please sign in to comment.