package A
Here is the contents of A/src/A.jl:
module A
struct Foo
x::Int
end
end # module
package C
Here is the contents of C/src/C.jl
module C
import A
using BSON
file = "/Users/anthony/test.bson"
f = BSON.load(file)[:f]
@show f
end # module
serializing and deserialising in the REPL
julia> import A
using BSON
f = A.Foo(7)
file = "/Users/anthony/test.bson"
bson(file, Dict(:f=>f))
humus:toml anthony$ julia # restarting the REPL
julia> import A
using BSON
file = "/Users/anthony/test.bson"
f = BSON.load(file)[:f]
A.Foo(7) # working as expected
instead importing C to deserialise:
julia> using C
[ Info: Precompiling C [371b88f8-98b2-11e9-0613-bf108cd8ab40]
ERROR: LoadError: UndefVarError: A not defined
Stacktrace:
[1] (::getfield(BSON, Symbol("##31#32")))(::Module, ::String) at /Users/anthony/.julia/packages/BSON/XPZLD/src/extensions.jl:20
[2] mapfoldl_impl(::typeof(identity), ::getfield(BSON, Symbol("##31#32")), ::NamedTuple{(:init,),Tuple{Module}}, ::Array{Any,1}) at ./reduce.jl:45
[3] #mapfoldl#187(::Base.Iterators.Pairs{Symbol,Module,Tuple{Symbol},NamedTuple{(:init,),Tuple{Module}}}, ::Function, ::Function, ::Function, ::Array{Any,1}) at ./reduce.jl:72
[4] #mapfoldl at ./none:0 [inlined]
[5] _mapreduce_dim at ./reducedim.jl:306 [inlined]
[6] #mapreduce#548 at ./reducedim.jl:304 [inlined]
[7] #mapreduce at ./none:0 [inlined]
[8] #reduce#549 at ./reducedim.jl:348 [inlined]
[9] (::getfield(Base, Symbol("#kw##reduce")))(::NamedTuple{(:init,),Tuple{Module}}, ::typeof(reduce), ::Function, ::Array{Any,1}) at ./none:0
[10] resolve(::Array{Any,1}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/extensions.jl:20
[11] (::getfield(BSON, Symbol("##35#36")))(::Dict{Symbol,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/extensions.jl:48
[12] _raise_recursive(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:79
[13] raise_recursive(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:89
[14] (::getfield(BSON, Symbol("##45#46")))(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/extensions.jl:133
[15] raise_recursive(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:88
[16] (::getfield(BSON, Symbol("##20#22")){IdDict{Any,Any}})(::Dict{Symbol,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:82
[17] applychildren!(::getfield(BSON, Symbol("##20#22")){IdDict{Any,Any}}, ::Dict{Symbol,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/BSON.jl:21
[18] _raise_recursive(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:82
[19] raise_recursive(::Dict{Symbol,Any}, ::IdDict{Any,Any}) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:89
[20] raise_recursive at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:99 [inlined]
[21] load(::String) at /Users/anthony/.julia/packages/BSON/XPZLD/src/read.jl:104
[22] top-level scope at none:0
[23] include at ./boot.jl:326 [inlined]
[24] include_relative(::Module, ::String) at ./loading.jl:1038
[25] include(::Module, ::String) at ./sysimg.jl:29
[26] top-level scope at none:2
[27] eval at ./boot.jl:328 [inlined]
[28] eval(::Expr) at ./client.jl:404
[29] top-level scope at ./none:3
in expression starting at /Users/anthony/Dropbox/Julia7/MLJ/MLJ/sandbox/toml/C/src/C.jl:7
ERROR: Failed to precompile C [371b88f8-98b2-11e9-0613-bf108cd8ab40] to /Users/anthony/.julia/compiled/v1.1/C/6eWus.ji.
Stacktrace:
[1] error(::String) at ./error.jl:33
[2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1197
[3] _require(::Base.PkgId) at ./loading.jl:960
[4] require(::Base.PkgId) at ./loading.jl:858
[5] require(::Module, ::Symbol) at ./loading.jl:853