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

Suggest Str.concat when trying to concat strings with + #6652

Open
XDracam opened this issue Apr 19, 2024 · 0 comments
Open

Suggest Str.concat when trying to concat strings with + #6652

XDracam opened this issue Apr 19, 2024 · 0 comments

Comments

@XDracam
Copy link

XDracam commented Apr 19, 2024

In the spirit of being beginner friendly: most programmers I know are used to concatenating two strings with +. Roc doesn't need this, but: it would be nice to suggest using Str.concat in the error message to reduce frustration for programmers coming from other languages.

The current output in the installed linux x86-64 binary (nightly from 2024/04/19) is this: (is the crash message intentional?)

» "Hi " + "There"
This Roc code crashed with: "Hit an erroneous type when creating a layout for `4.IdentId(19)`"

── TYPE MISMATCH ───────────────────────────────────────────────────────────────

This 1st argument to + has an unexpected type:

6"Hi " + "There"
        ^^^^^

The argument is a string of type:

    Str

But + needs its 1st argument to be:

    Num a

I'd suggest appending a line like Hint: Strings in Roc can be concatenated using Str.concat

(Please tell me if this is not a good contribution)

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