Skip to content

Commit

Permalink
fix #29936, precompile should not assume UnionAlls have stable addres…
Browse files Browse the repository at this point in the history
…ses (#31047)

(cherry picked from commit 2dd48b9)
  • Loading branch information
JeffBezanson authored and KristofferC committed Feb 20, 2020
1 parent a092d2a commit 7fcbd01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ static int type_parameter_recursively_external(jl_value_t *p0)
return 0;
if (module_in_worklist(p->name->module))
return 0;
if (p->name->wrapper != (jl_value_t*)p0) {
if (jl_unwrap_unionall(p->name->wrapper) != (jl_value_t*)p) {
if (!type_recursively_external(p))
return 0;
}
Expand Down Expand Up @@ -743,7 +743,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) && d->name->wrapper == v &&
if (jl_is_datatype(d) && jl_unwrap_unionall(d->name->wrapper) == (jl_value_t*)d &&
!module_in_worklist(d->name->module)) {
write_uint8(s->s, 1);
jl_serialize_value(s, d->name->module);
Expand Down
22 changes: 22 additions & 0 deletions test/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -744,5 +744,27 @@ let
end
end

# issue #29936
let
load_path = mktempdir()
load_cache_path = mktempdir()
try
write(joinpath(load_path, "Foo29936.jl"),
"""
module Foo29936
const global m = Val{nothing}()
const global h = Val{:hey}()
wab = [("a", m), ("b", h),]
end
""")
pushfirst!(LOAD_PATH, load_path)
pushfirst!(DEPOT_PATH, load_cache_path)
@eval using Foo29936
@test [("Plan", Foo29936.m), ("Plan", Foo29936.h),] isa Vector{Tuple{String,Val}}
finally
rm(load_path, recursive=true)
rm(load_cache_path, recursive=true)
end
end

end # !withenv

0 comments on commit 7fcbd01

Please sign in to comment.