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

[SR-11261] Parser recovery for keyword after 'case' declaration #53662

Closed
rintaro mannequin opened this issue Aug 5, 2019 · 2 comments
Closed

[SR-11261] Parser recovery for keyword after 'case' declaration #53662

rintaro mannequin opened this issue Aug 5, 2019 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers parser Area → compiler: The legacy C++ parser

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Aug 5, 2019

Previous ID SR-11261
Radar None
Original Reporter @rintaro
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser, StarterBug
Assignee @LucianoPAlmeida
Priority Medium

md5: 16372c922ff6586681a92408bef937a4

Issue Description:

enum Token {
  case identifier
  case operator
}

results

test.swift:3:8: error: expected pattern
  case operator
       ^
test.swift:3:8: error: keyword 'operator' cannot be used as an identifier here
  case operator
       ^
test.swift:3:8: note: if this name is unavoidable, use backticks to escape it
  case operator
       ^~~~~~~~
       `operator`
test.swift:3:7: error: consecutive declarations on a line must be separated by ';'
  case operator
      ^
      ;
test.swift:3:16: error: expected operator name in operator declaration
  case operator
               ^

whereas only these 2 should be emitted:

test.swift:3:8: error: keyword 'operator' cannot be used as an identifier here
  case operator
       ^
test.swift:3:8: note: if this name is unavoidable, use backticks to escape it
  case operator
       ^~~~~~~~
       `operator`

This should be improved if the parser consumes "operator" as if it's properly escaped.

@LucianoPAlmeida
Copy link
Collaborator

@rintaro What is the state of this, Is anyone working on this already? if not I can take it 🙂

@LucianoPAlmeida
Copy link
Collaborator

Here's a PR #26596

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant