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 not recovering properly from broken contract #1189

Open
beta-ziliani opened this issue Dec 12, 2024 · 1 comment
Open

Parser not recovering properly from broken contract #1189

beta-ziliani opened this issue Dec 12, 2024 · 1 comment
Assignees

Comments

@beta-ziliani
Copy link
Contributor

The following file generates just one ContractDefinition node, when there should be two.

contract A {
  public function // missing the rest...
}

contract B {
  public function // missing the rest...
}

Current output:

Tree:
  - (ContractDefinition): # "contract A {\n  public function // missing the rest..." (0..113)
      - (contract_keyword꞉ ContractKeyword): "contract" # (0..8)
      - (leading_trivia꞉ Whitespace): " " # (8..9)
      - (name꞉ Identifier): "A" # (9..10)
      - (leading_trivia꞉ Whitespace): " " # (10..11)
      - (open_brace꞉ OpenBrace): "{" # (11..12)
      - (trailing_trivia꞉ EndOfLine): "\n" # (12..13)
      - (members꞉ ContractMembers): [] # (13..13)
      - (leading_trivia꞉ Whitespace): "  " # (13..15)
      - (UNRECOGNIZED): "public function // missing the rest...\n" # (15..54)
      - (close_brace꞉ CloseBrace): "}" # (54..55)
      - (trailing_trivia꞉ EndOfLine): "\n" # (55..56)
      - (leading_trivia꞉ EndOfLine): "\n" # (56..57)
      - (UNRECOGNIZED): "contract B {\n  public function // missing the rest..." # (57..113)

Note that also the first function is not parsed as such.

Originally found in collaboration with @OmarTawfik in #1172 (comment)

@AntonyBlakey
Copy link
Contributor

I don't think this should be an issue. Trying to apply this form of reasoning to error recovery is a entire rabbit warren of distractions. I think you are judging this on the basis of what you know the user intended, which of course the parser does not.

Making this work in the general case requires a different set of tradeoffs in the parser, and making it work in the specific case really is whack-a-mole.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants