Skip to content

Commit

Permalink
Fix Vararg separately
Browse files Browse the repository at this point in the history
  • Loading branch information
darsnack committed Feb 12, 2022
1 parent accf1da commit e32fd5d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/anonymous.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ function newstruct!(meth::Method, mod, name, file, line, sig,
end
end

# Type Names

if VERSION < v"1.7-"
function structdata(t::TypeName)
primary = Base.unwrap_unionall(t.wrapper)
Expand All @@ -83,7 +85,10 @@ function structdata(t::TypeName)
end
end

# Type Names
if VERSION >= v"1.7-"
structdata(x::Core.TypeofVararg) =
Any[getfield(x, f) for f in fieldnames(typeof(x)) if isdefined(x, f)]
end

baremodule __deserialized_types__ end

Expand Down
20 changes: 20 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ end
@test x.x === x
end

@testset "Undefined References" begin
# from Issue #3
d = Dict(:a => 1, :b => Dict(:c => 3, :d => Dict("e" => 5)))
@test roundtrip_equal(d)

# from Issue #43
x = Array{String, 1}(undef, 5)
x[1] = "a"
x[4] = "d"
@test_broken roundtrip_equal(Dict(:x => x))

struct NoInit
x::Int

NoInit() = new()
end
x = NoInit()
@test roundtrip_equal(x)
end

@testset "Anonymous Functions" begin
f = x -> x+1
if VERSION < v"1.7-"
Expand Down

0 comments on commit e32fd5d

Please sign in to comment.