From 1812a8af61d60897336dc42bce32c41de7a90813 Mon Sep 17 00:00:00 2001 From: kshramt Date: Sat, 11 Feb 2017 16:19:32 +0900 Subject: [PATCH] Make `T{typeof(f)}()` `load`able again This patch fixes a regression introduced by 94af823c621a9e5cb5fcd8af1c364a2f3197ce22. Now the return value of `Optim.optimize` is `load`able again. --- src/JLD.jl | 7 ++++--- test/jldtests.jl | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/JLD.jl b/src/JLD.jl index 730a21d..a459647 100644 --- a/src/JLD.jl +++ b/src/JLD.jl @@ -991,10 +991,11 @@ end function _julia_type(s::AbstractString) typ = get(_typedict, s, UnconvertedType) if typ == UnconvertedType - sp = parse(s, raise=false) - if (isa(sp, Expr) && (sp.head == :error || sp.head == :continue || sp.head == :incomplete)) + sp = try + parse(s) + catch err println("error parsing type string ", s) - eval(sp) + rethrow(err) end typ = julia_type(fixtypes(sp)) if typ != UnsupportedType diff --git a/test/jldtests.jl b/test/jldtests.jl index 8e7393a..cacf60b 100644 --- a/test/jldtests.jl +++ b/test/jldtests.jl @@ -953,6 +953,14 @@ f2() @test loadmacrotestvar1 == ['a', 'b', 'c'] @test loadmacrotestvar2 == 1 +mktempdir() do dir + cd(dir) do + JLD.save("_.jld", "_", Val{typeof(sin)}()) + # should not throw an error + JLD.load("_.jld", "_") + end +end + # Test StackFrame by saving profile output @profile eigvals(randn(3,3)) li, lidict = Profile.retrieve()