Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make type errors about effectfulness more obvious #7426

Open
smores56 opened this issue Dec 28, 2024 · 1 comment
Open

Make type errors about effectfulness more obvious #7426

smores56 opened this issue Dec 28, 2024 · 1 comment
Labels
error-messages Related to the quality of error messages intermediate issue Likely good for someone who has completed a few other issues type checking Relates to type checking compiler stage

Comments

@smores56
Copy link
Collaborator

Today, the following code produces a difficult to understand error:

module [broken, func!]

func! : Str => Result Str []

broken = List.map [] func!

When run against roc check:

── TYPE MISMATCH in test.roc ───────────────────────────────────────────────────

This 2nd argument to map has an unexpected type:

5│  broken = List.map [] func!
                         ^^^^^^^^^^

This func! value is a:

    Str => Result Str []

But map needs its 2nd argument to be:

    Str -> Result Str []

────────────────────────────────────────────────────────────────────────────────

1 error and 0 warnings found in 30 ms.

This tells us that the first function is effectful with a => and the second is pure with a ->. This is hard to distinguish at a glance, we'd like to make it more obvious. It would be nice for the error to say something along the lines of "This function is effectful, but it needs to be pure".

@smores56 smores56 added type checking Relates to type checking compiler stage intermediate issue Likely good for someone who has completed a few other issues labels Dec 28, 2024
@lukewilliamboswell lukewilliamboswell added the error-messages Related to the quality of error messages label Dec 28, 2024
@Anton-4
Copy link
Collaborator

Anton-4 commented Dec 30, 2024

Having ^^ below the differing chars (=> and ->) would be nice as well.

@smores56 smores56 changed the title Make Make type errors about effectfulness more obvious Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error-messages Related to the quality of error messages intermediate issue Likely good for someone who has completed a few other issues type checking Relates to type checking compiler stage
Projects
None yet
Development

No branches or pull requests

3 participants