Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DynamicPPL"
uuid = "366bfd00-2699-11ea-058f-f148b4cae6d8"
version = "0.12.2"
version = "0.12.3"

[deps]
AbstractMCMC = "80f14c24-f653-4e6a-9b94-39d6b0f70001"
Expand Down
37 changes: 5 additions & 32 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,39 +44,12 @@ function getargs_tilde(expr::Expr)
end
end

############################################
# Julia 1.2 temporary fix - Julia PR 33303 #
############################################
function to_namedtuple_expr(syms, vals=syms)
if length(syms) == 0
nt = :(NamedTuple())
else
nt_type = Expr(
:curly,
:NamedTuple,
Expr(:tuple, QuoteNode.(syms)...),
Expr(:curly, :Tuple, [:(Core.Typeof($x)) for x in vals]...),
)
nt = Expr(:call, :($(DynamicPPL.namedtuple)), nt_type, Expr(:tuple, vals...))
end
return nt
end

if VERSION == v"1.2"
@eval function namedtuple(
::Type{NamedTuple{names,T}}, args::Tuple
) where {names,T<:Tuple}
if length(args) != length(names)
throw(ArgumentError("Wrong number of arguments to named tuple constructor."))
end
# Note T(args) might not return something of type T; e.g.
# Tuple{Type{Float64}}((Float64,)) returns a Tuple{DataType}
return $(Expr(:splatnew, :(NamedTuple{names,T}), :(T(args))))
end
else
function namedtuple(::Type{NamedTuple{names,T}}, args::Tuple) where {names,T<:Tuple}
return NamedTuple{names,T}(args)
end
length(syms) == 0 && return :(NamedTuple())

names_expr = Expr(:tuple, QuoteNode.(syms)...)
vals_expr = Expr(:tuple, vals...)
return :(NamedTuple{$names_expr}($vals_expr))
end

#####################################################
Expand Down