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

Provide a nice error message when trying to compare two Str #7667

Open
Anton-4 opened this issue Mar 5, 2025 · 0 comments
Open

Provide a nice error message when trying to compare two Str #7667

Anton-4 opened this issue Mar 5, 2025 · 0 comments

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Mar 5, 2025

NOTE: do not implement this in the old rust compiler, only in the new zig compiler (see src folder) when it is far enough along.

"abc" < "def"

currently results in:

This 1st argument to > has an unexpected type:

4│ "abc" > "dev"
^^^^^
The argument is a string of type:
Str
But > needs its 1st argument to be:
Num a

It's hard to figure out for the user how they can implement their desired behavior.
We should intercept this particular type error and add a nice message with a link to "Why does Roc not handle strings like most languages?" in the faq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant