Confusing error from @lens _.[:a]
Closed this issue · 6 comments
tkf commented
julia> @lens _[:a]
(@lens _[:a])
julia> @lens _.[:a]
ERROR: TypeError: in Type, in parameter, expected Type, got Expr
Stacktrace:
[1] top-level scope at REPL[36]:1
julia> @macroexpand @lens _.[:a]
:(Setfield.compose(Setfield.PropertyLens{$(QuoteNode(:([:a])))}()))
Note the .
before [:a]
.
jw3126 commented
Was the @lens _.[:a]
a typo or did you expect any particular semantics?
tkf commented
Sorry, I should've clarified that it was about error handling. I think it would be nice to throw an error inside the macro.
(We probably can add some meaning to it after Julia adds getindex broadcasting.)
tkf commented
We also need to allow String
. I just mark it as good first issue
(although maybe I'll do it at some point).
jw3126 commented
Yeah, I already had kind of a bad feeling when I wrote Symbol
. Good idea to label this first issue.