Compiler error message suggestion

I use C# and TypeScript where the convention is to capitalize type names. When I type this below, Rescript gives me a very unhelpful message. I’ve encountered this many times and because it looks correct to me I end up commenting out a bunch of code above/below figuring the error is somewhere else. Eventually I figure it out. This has happened to me many times. I really wish the error message was something like “Type names must be lowercase.”

type Point = { // ERROR: did you forget a . here?
  x: int,
  y: int,
}

Occasionally I type stuff like this and get a different and also unhelpful error message. Again, it would be better if the error message was more specific like “Records need at least one field designated by a lowercase identifier.”

type point = { // ERROR: A record needs at least one field
  X: int,
  Y: int,
}

Is it just me, or does anyone else get tripped up by these compiler error messages?

5 Likes

Agreed. Looking at https://github.com/rescript-lang/syntax/blob/master/src/res_core.ml#L4217-L4219 I don’t think it would be too hard to change this behaviour to also recognize when there’s a Uident (uppercase identifier) and then report an appropriate error message.

Right now it calls parseLident with whatever the next token is. While we could updating parseLident to complain if it gets a Uident, I think have the error message reported by parseFieldDeclaration will allow us to have a more helpful error message. Although having a backup error message in parseLident as well is probably not a bad idea.

1 Like

There’s an open PR related to this https://github.com/rescript-lang/syntax/pull/424

3 Likes

Not a good sign that such a bug takes over a year to resolve. Somehow we need more support (probably paid) for developing this language. People coming from Typescript will get frustrated with this problem. I wonder if there is a hack - like appending something to the existing error message like “Type names in ReScript must be capitalized.” I don’t know when the current error message actually makes sense.

You know how it is with open source–it means that it wasn’t a high enough priority for anyone (including users) to put either their effort or money into it. Doesn’t mean it’s not important, but that there are a ton of more important things.

Somehow we need more support (probably paid) for developing this language.

I’m sure the ReScript team would welcome some funds :slight_smile:

I’m totally agree with you! :sweat:

is there a direct rescript team dontation? I saw a foundation thing but it was a little unclear the affiliation and what that money would be put to.

Yes, this page has more details: Donate | ReScript Association