Skip to content

argument order errors overwhelming. #357

@sijmenvb

Description

@sijmenvb

for a simple expression such as
querry1 = String.repeat "Hi " 5
I get two errors that manage to fill my entire screen they boil down to:
expected string got int
and expected int got string
the problem here is obvious, I messed up the order of the arguments.
The hints I get are to use String.fromInt and String.toInt
But I would also expect a hint like:

Hint: maybe you meant the following order of arguments:
    String.repeat 5 "Hi " 
Since this is a valid expression.

In general I would expect such a suggestion every time changing the order of arguments would lead to a valid expression.

(in the compiler, just add all the argument's types to a list and then go trough the type of the function and put them in (and remove them (first in first out?) from that list) only if this succeeds give the hint.)

This would help parse these "dumb mistake" errors much easier and it would also be nice for library functions you don't use often since you can just give the arguments in any order and the compiler would tell you what (the/a) right order is. Why would I need to remember the correct order?
also, being able to copy paste the suggested code in is certainly quicker than moving arguments around manually.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions