You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On master we have the following behavior for a test-case in Turing.jl:
```julia
julia> @macroexpand@model empty_model() = begin x = 1; end
quote
function empty_model(__model__::DynamicPPL.Model, __varinfo__::DynamicPPL.AbstractVarInfo, __context__::DynamicPPL.AbstractContext; )
#= REPL[5]:1 =#
begin
#= REPL[5]:1 =#
#= REPL[5]:1 =#
return (x = 1, __varinfo__)
end
end
begin
$(Expr(:meta, :doc))
function empty_model(; )
#= REPL[5]:1 =#
return (DynamicPPL.Model)(:empty_model, empty_model, NamedTuple(), NamedTuple())
end
end
end
```
Notice the `return` statement: it converted the statement `x = 1` which returns `1` into an attempt at a `NamedTuple{(:x, :__varinfo__)}`. On Julia 1.6 we don't really notice much of difference, because `first` and `last` will have the same behavior, but on Julia 1.3 the tests would fail in TuringLang/Turing.jl#1726 since "implicit" names in construction of `NamedTuple` isn't supported.
This PR addresses this issue by simply capturing the return-value in separate variable, which is then combined with `__varinfo__` in a `Tuple` at the end. This should both fail and succeed whenever standard Julia code would.
0 commit comments