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

Recover from unclosed class << self #5445

Open
jez opened this issue Mar 9, 2022 · 0 comments
Open

Recover from unclosed class << self #5445

jez opened this issue Mar 9, 2022 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers parser Bug or limitation in Sorbet's parser

Comments

@jez
Copy link
Collaborator

jez commented Mar 9, 2022

Input

→ View on sorbet.run

# typed: true

class A
  class << self
end

Observed output

s(:begin)
editor.rb:5: unexpected token "end of file" https://srb.help/2001
     5 |end
     6 |
Errors: 1

Expected behavior

Sorbet should produce a parse result, instead of an empty parse result.


This doesn't matter quite as much as other parse results, because adding this line will force us to take the slow path still, but at least error messages will get better (and if you didn't fix the syntax error fast enough, we might be able to start showing completion requests in the class body eventually).

Note that we already recover for most other forms of mismatched end. See the changes in #5383 for inspiration on how to fix this.

@jez jez added bug Something isn't working good first issue Good for newcomers parser Bug or limitation in Sorbet's parser labels Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers parser Bug or limitation in Sorbet's parser
Projects
None yet
Development

No branches or pull requests

1 participant