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

Parser errors prevent CodeProvider execution (completion, goto definition etc) #104

Open
simerplaha opened this issue Feb 14, 2024 · 1 comment
Assignees
Labels
area:code-completion code completion area:compiler For RalphC type:bug Something isn't working

Comments

@simerplaha
Copy link
Member

simerplaha commented Feb 14, 2024

Code completion relies on the parsed AST. When the parser fails, the AST (parser) becomes unavailable for code completion.

For example: The following test fails because contract is not a valid keyword, which gets rejected by the ralphc parser, making the AST (parser) unavailable for code completion at line 1.

val suggestions =
  TestCodeCompleter(
    """
      |import "std/@@"
      |
      |contract Test() { }
      |""".stripMargin)

suggestions should not be empty

This will be case for all code completion providers and every other implementation that needs the AST like go-to definitions, quick-fix suggestions etc.

@simerplaha simerplaha added type:bug Something isn't working area:compiler For RalphC area:code-completion code completion labels Feb 14, 2024
@simerplaha simerplaha changed the title Parser errors prevent code completion Parser errors prevent CodeProvider execution (completion, goto definition etc) Mar 7, 2024
@simerplaha
Copy link
Member Author

simerplaha commented Mar 13, 2024

Hey @tdroxler, just wanted to draw your attention to this issue. It's can be a bit annoying that a single parser error disables LSP features such as go-to definition and auto-completion due to the unavailability of the AST (see above example scenario). Ralph's parser is a bit too strict for us at the moment. It would be nice if most errors could be deferred to the compilation phase.

For example:

  • Instead of immediately flagging priv fn as an error in the parser, priv could be stored as Ast.FuncModifier and validated during compilation.
  • Errors like checking duplicate enum fields, empty fields, etc., don't necessarily need to be parser errors, they could be handled as compilation errors.
  • The syntax MyEnum. or myEnum. is also immediately rejected by the parser, thus preventing autocomplete after the dot.
  • There are a few other cases like these.

If the parser could parse the syntax with a bit more flexibility, developers might intentionally write incorrect code, relying on auto-complete to catch these mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:code-completion code completion area:compiler For RalphC type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant