Closed fuelen closed 1 year ago
also, if I forget to type a map
key:
param :id, &to_string/1
then I receive a cryptic error:
== Compilation error in file lib/test_schema.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:&, [line: 6], [{:/, [line: 6], [{:to_string, [line: 6], nil}, 1]}]} of type Tuple
(elixir 1.14.3) lib/enum.ex:1: Enumerable.impl_for!/1
(elixir 1.14.3) lib/enum.ex:166: Enumerable.reduce/3
(elixir 1.14.3) lib/enum.ex:4307: Enum.map/2
These should all be handleable things. Thanks for the report :) I'll look into it soon.
functions like & &1
and & &1.id
still don't work.
Seems like because the line is hardcoded [line: 113]
Oops :) Sorry about that.
I was testing and left that in.
Fixed :)
Cool! Thank you for quick fixes :)
My pleasure :D
Describe the bug In some cases, it is not possible to pass a function as a value.
To Reproduce Let's say we have an entity with optional
map
parameter which accepts functions with arity 1:This works:
this doesn't:
error:
if I rewrite this using do/end blocks, then it works:
this doesn't:
error (arity is detected incorrectly):
this doesn't work as well, but with different error:
error:
but this works
Expected behavior It would be great if all cases above work, especially one-liners like
param :id, map: & &1.id
Runtime