-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add error case for unnamed arguments #315
Conversation
This should not error, I think? We might want to use them as @model demo(::T=Float64) where T
x = Vector{T}(undef, 10)
x .~ Normal()
return x
end Here |
I thought we always supported this but maybe we dropped it accidentally at some point 🤔 |
OK, interesting. But how would those arguments be stored in the model? Perhaps it was caused by |
Ah wait, I take this back 😄 One always had to use |
The example would still make sense (I think) but it is not supported and type won't be adjusted (since then we would have to instantiate values at some point...). |
Right, and it can't currently reasonably be supported, since we'd have to make up a name for the argument. The PR doesn't change that behaviour, it just improves the error. Supporting that kind of argument can IMHO reasonably be done by gensyming something and perhaps emit a warning, but that's a separate issue. |
@yebai's opionon is that we might just generate names. Now, the normal lowering uses the pattern julia> bar(::Int, ::Bool) = nothing
bar (generic function with 1 method)
julia> @code_warntype bar(1, true)
Variables
#self#::Core.Const(bar)
#unused#@_2::Int64
#unused#@_3::Bool
Body::Nothing
1 ─ return Main.nothing I think if we do just that and rename all argument names, we should get everything for free, right? I'm basing this on two assumptions:
(And if you want to see some |
Thinking once more about it -- this, too, is one of the cases that are automatically resolved if the |
@phipsgabler Can you clarify why the unnamed argument issue will disappear if we remove the prob macro? |
@yebai The only reason And the origin for the above bug, or rather the special treatment of |
@devmotion @phipsgabler I think #394 fixed the issue here. Please reopen if otherwise. |
Ha I didn't remember this PR 😅 |
Model arguments without names (
f(x, ::T)
) don't really make sense -- we can't put them in theargs
named tuple.What currently happens is a bit weird, since we produce a syntactically invalid macro output:
With this PR, it is caught during
build_model_info
:(The alternative would be to generate some symbol, but I don't see how that is useful.)