asoffer / Icarus

An experimental general-purpose programming language
Apache License 2.0
9 stars 2 forks source link

Argument type checking doesn't print the given type name #64

Closed perimosocordiae closed 2 years ago

perimosocordiae commented 3 years ago

This one is easier to demo than describe:

foo ::= (a: i64) => a
foo("s")

Output:

Expression cannot be called with the given arguments.

  3 | foo("s")
  * (a: i64) -> (i64) -- Parameter at index 0 cannot accept an argument of type `at index 0`
asoffer commented 3 years ago

This bug was introduced somewhat intentionally as a short term solution. In order to make diagnostics show the best name for a type based on context near the error (see #57), we need to pass a AST expressions in to the function generating the diagnostic. This particular function doesn't have easy access, so instead, to reduce the size and scope of the commit, I temporarily made the diagnostic worse.