Skip to content

Improve error message when using keyword as field name #7579

Open
@zth

Description

@zth

Adding a field name that's a keyword like type gives a very cryptic error:

type record ={
  id: string,
  type: int
}
Syntax Errors
The code is not valid ReScript syntax.
[E] Line 2, column 13:
Did you forget a `}` here?
[E] Line 3, column 6:
I'm not sure what to parse here when looking at ":".
[E] Line 4, column 0:
I'm not sure what to parse here when looking at "}".

We should be able to say what the problem is here (keyword as field name)? And suggest a fix (like @as("type") type_).

There are probably more cases like this when keywords are used in places they shouldn't be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions