Skip to content

More helpful syntax error messages #9

Open
@anko

Description

@anko

Syntax errors look like this right now:

$ eslc <<< "("

/home/an/code/eslisp/node_modules/sexpr-plus/index.js:1054
      throw peg$buildException(null, peg$maxFailExpected, peg$maxFailPos);
      ^
SyntaxError: Expected ")", comment or whitespace but end of input found.

The SyntaxError-object sexpr-plus returns has line and column properties. We should perhaps use them.


Invalid AST errors look like this:

$ eslc <<< "(+ x %)"
{ [InvalidAstError: Identifier `name` member must be a valid IdentifierName]
  node: { type: 'Identifier', name: '%' },
  message: 'Identifier `name` member must be a valid IdentifierName' }
x + %;

That's already getting there, but it would still be best if exact positions in code were passed on to AST nodes, so the error reporter could point out the exact in-source position that an error happened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions