For example in cases such as:
defp comparison(left_head | left_tail, [], result \\ "") do
Or alternatively we can improve unknown | altogether, even outside of patterns.
What is the error in your given example? It looks like normal [head|tail] matching?
Or is this for when the | operator is overridden?
Oops, I have updated the example. It will say unknown function | and we can provide some pointers. The same for ::.
Ah, makes much more sense! ^.^
If you're okay with it, I'd like to see if I can take it, but I need more hints to start, I'm a newcomer.
Thanks!
@dsantosmerino the tricky part on this one is not the implementation but writing the error message and I still do not know how that should look like. If anyone has suggestions, please let us know.
@josevalim what if I redefine my own | operator which is not context-dependent?
@whatyouhide we will only raise if there is no overriding (that's already how it works btw, we are just improving the message for certain cases).
@josevalim How about this one?
Misused operator `|` in function definition at {file}:{line}:
defp comparison(left_head [red]|[/red] left_tail, [], result \\ "") do
If you were trying to match on list head and tail, you need to wrap this expression with square brackets. See more at https://elixir-lang.org/getting-started/pattern-matching.html.
And similar for ::.
Most helpful comment
@josevalim How about this one?
And similar for
::.