elm / error-message-catalog

A catalog of broken Elm programs / data to improve error messages
BSD 3-Clause "New" or "Revised" License
173 stars 17 forks source link

Naming error when tuple result on lambda has no parens #335

Open reinux opened 4 years ago

reinux commented 4 years ago

This might be a mistake that's unique to people coming from OCaml/F#, but:

tasks |> List.map (\t -> t.id, t)

The mistake was in forgetting the brackets on the result tuple (F# doesn't require commas around tuples, as it uses semicolons for list comprehensions instead).

The error I get:

NAMING ERROR - I cannot find a `t` variable:
191|         |> List.map (\t -> t.id, t)
                                      ^

I'm not sure this would be easy to improve, since it can't be helped that the -> operator has higher precedence than ,.