I used a function argument inconsistently, where one use treated it like a record, and another as a comparable. The first use was correct, and the second was a mistake. The error message pointed to the correct use and didn't mention the incorrect one. It took a while to realize where I'd made the mistake.
I created a function without annotations, like so:
import Dict
f record =
let x = record.a
y = Dict.get record Dict.empty -- accidentally typed "record" rather than "record.a"
in 0
and misused record. The compiler gave the following message:
While the y = definition is where I made the mistake, the compiler doesn't mention it. In this case, it would be great for the compiler to say something like " in y = ..., record is a comparable, but in x = ... it's being treated like a {a: a}.
I get a much better error message after adding a type annotation to the function.
import Dict
f: {a: String} -> Int
f record =
let x = record.a
y = Dict.get record Dict.empty -- accidentally typed "record" rather than "record.a"
in 0
I used a function argument inconsistently, where one use treated it like a record, and another as a
comparable
. The first use was correct, and the second was a mistake. The error message pointed to the correct use and didn't mention the incorrect one. It took a while to realize where I'd made the mistake.I created a function without annotations, like so:
and misused
record
. The compiler gave the following message:While the
y =
definition is where I made the mistake, the compiler doesn't mention it. In this case, it would be great for the compiler to say something like " iny = ...
, record is acomparable
, but inx = ...
it's being treated like a{a: a}
.I get a much better error message after adding a type annotation to the function.