Stream: contributing

Topic: Good error message for provides


view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:06):

I am looking at good first issues. I saw this one. @Anton You raised this one. I think I have a solution but I'm not sure. Do I just submit a PR to review, or do you want to discuss here first?

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:11):

I just changed ine 3472 from crates/reporting/src/error/parse.rs to be EProvides::Provides(pos) | EProvides::IndentProvides(pos) => {. I figured it should be the same error message

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:14):

The last line in the error message does not have a newline however, which means the next shell prompt will be on the same line as the last line in the error. This is not ideal

view this post on Zulip Anton (Jun 27 2023 at 17:45):

Thanks @Kilian Vounckx, that approach sounds good. @Folkert de Vries do you know how we can add a newline at the end here?

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:45):

is it this message specifically, or in general?

view this post on Zulip Anton (Jun 27 2023 at 17:49):

This message specifically, I suppose

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:52):

EGeneratesWith::Identifier(pos)
This tag has the same issue, so I think it is at least two, so I suppose in general

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:52):

but some get it right

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:52):

right?

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:52):

I don't know how to trigger all of them

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:53):

messing up header parsing is relatively easy

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:53):

make up some fancy new infix operator that does not parse, etc

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:53):

Kilian Vounckx said:

EGeneratesWith::Identifier(pos)
This tag has the same issue, so I think it is at least two, so I suppose in general

Oh I meant this one EProvides::Identifier(pos)

view this post on Zulip Folkert de Vries (Jun 27 2023 at 17:53):

also we have tests for the reporting of parse errors

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:57):

This one EExposes::Identifier(pos) for interface exposes lists has the same issue again

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 17:57):

I'll try to find a correct one

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:02):

I did find another issue when looking:

interface Foo
    exposes []
    imports [foo]

When running roc check Foo.roc on this file, it gives an EImports::ListEnd error instead of an EImports::ModuleName error.

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:02):

Its error message is

── WEIRD IMPORTS ───────────────────────────────────────────────────── Foo.roc ─

I am partway through parsing a imports list, but I got stuck here:

2│      exposes []
3│      imports [foo]
                 ^

I am expecting a comma or end of list, like
    imports [Shape, Vector]

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:03):

Again with no newline

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:10):

After trying between five or ten which I knew how to trigger at random, all of them did not have the newline, so I think it is a general issue

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:11):

I will finish the original issue about the specific error message, and I think the newlines is a new issue

view this post on Zulip Folkert de Vries (Jun 27 2023 at 18:11):

do e.g. type checker reports also have this problem?

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:13):

Kilian Vounckx said:

I will finish the original issue about the specific error message, and I think the newlines is a new issue

@Anton PR submitted

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:13):

Folkert de Vries said:

do e.g. type checker reports also have this problem?

I'll try to find some

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:17):

Folkert de Vries said:

do e.g. type checker reports also have this problem?

interface Foo
    exposes []
    imports []

foo : Str -> Str
foo = \x -> x + 1

The type error on this file has a newline

view this post on Zulip Folkert de Vries (Jun 27 2023 at 18:18):

ok, so there is some inconsistency between parse and type error formatting, right?

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:21):

I think so

view this post on Zulip Kilian Vounckx (Jun 27 2023 at 18:53):

@Anton I added the test

view this post on Zulip Folkert de Vries (Jun 27 2023 at 19:08):

btw https://github.com/roc-lang/roc/pull/5607 may also be relevant here

view this post on Zulip Folkert de Vries (Jun 27 2023 at 19:08):

that one is ready to merge, but maybe can be folded into something bigger

view this post on Zulip Kilian Vounckx (Jul 03 2023 at 12:27):

@Folkert de Vries I was doing some unrelated stuff and found the following related issue.

This file is saved in Foo.roc:

interface Foo
    exposes []
    imports []

foo : F64
foo = 42

bar : F64
bar = 31

expect
    foo != bar

When running roc check Foo.roc, the error message has a newline at the end. However, when running roc test Foo.roc, the error does not have the newline. The only difference is checking vs testing


Last updated: Jul 06 2025 at 12:14 UTC