diff --git a/Project.toml b/Project.toml index e17343312..e2c1dd29e 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/src/utils.jl b/src/utils.jl index e77a4ecdd..db7faabbd 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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 #####################################################