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

Very bad error message when doing basic-cli upgrade #7508

Open
Anton-4 opened this issue Jan 13, 2025 · 1 comment
Open

Very bad error message when doing basic-cli upgrade #7508

Anton-4 opened this issue Jan 13, 2025 · 1 comment
Labels
error-messages Related to the quality of error messages P-high High priority/frequency

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Jan 13, 2025

❯ roc check examples/getVisualWidth.roc 

── UNRECOGNIZED NAME in examples/../../basic-cli/platform/main.roc ─────────────

The #UserApp module does not expose anything by the name 1.


── UNRECOGNIZED NAME in examples/../../basic-cli/platform/main.roc ─────────────

The #UserApp module does not expose anything by the name 1.

With the code:

app [main] {
    pf: platform "../../basic-cli/platform/main.roc",
    unicode: "../package/main.roc", # use release URL (ends in tar.br) for local example, see github.com/roc/unicode/releases
}

import pf.Stdout
import unicode.CodePoint

word = "世界"

## Get the display width (in amount of characters) of a Str
get_visual_width : Str -> Result U32 CodePoint.Utf8ParseErr
get_visual_width = \str ->
    str
    |> Str.to_utf8
    |> CodePoint.parse_utf8
    |> Result.map(\lst -> List.map(lst, CodePoint.visual_width))
    |> Result.map(List.sum)

main =
    when get_visual_width(word) is
        Ok(width) -> Stdout.line("\n\nThe word ${word} will be displayed with the width of ${Num.to_str(width)} characters on most UIs.\n\n")
        Err(_) -> crash("ERROR: Unable to parse ${word}!")

expect (get_visual_width(word)) == Ok(4)

This happens if you forget the ! after main.

@Anton-4 Anton-4 added error-messages Related to the quality of error messages P-high High priority/frequency labels Jan 13, 2025
@lukewilliamboswell
Copy link
Collaborator

lukewilliamboswell commented Jan 14, 2025

(deleted) -- nvm, I was thinking of another bug

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 P-high High priority/frequency
Projects
None yet
Development

No branches or pull requests

2 participants