-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@model macro breaks on conditional branches with return values #511
Comments
Just to it's clear, this does not require usage of julia> @model function demo()
if true
return nothing
else
return 0
end
end
demo (generic function with 2 methods)
julia> demo()()
ERROR: MethodError: no method matching iterate(::Nothing)
Closest candidates are:
iterate(::Union{LinRange, StepRangeLen})
@ Base range.jl:880
iterate(::Union{LinRange, StepRangeLen}, ::Integer)
@ Base range.jl:880
iterate(::T) where T<:Union{Base.KeySet{<:Any, <:Dict}, Base.ValueIterator{<:Dict}}
@ Base dict.jl:698
...
Stacktrace:
[1] first(itr::Nothing)
@ Base ./abstractarray.jl:465
[2] (::Model{typeof(demo), (), (), (), Tuple{}, Tuple{}, DefaultContext})()
@ DynamicPPL /drive-2/Projects/public/DynamicPPL.jl/src/model.jl:860
[3] top-level scope
@ REPL[20]:1 |
Merged
github-merge-queue bot
pushed a commit
that referenced
this issue
Aug 4, 2023
* fix for #511 * revert to previous behavior but with recursive application of replace_returns in return statements * use Val in the tests for return-values rather than something like missing and nothing * Update src/compiler.jl * Update src/compiler.jl * bumped patch version
This should be fixed in #512 :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As discussed with @torfjelde on Slack, here is a minimal example:
which results in:
In other cases, depending on what is returned, the error may be different.
The text was updated successfully, but these errors were encountered: