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-13964] Misleading diagnostics on missing closing brace for a property accessor #56361

Open
typesanitizer opened this issue Dec 13, 2020 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself parser Area → compiler: The legacy C++ parser

Comments

@typesanitizer
Copy link

Previous ID SR-13964
Radar rdar://problem/72273971
Original Reporter @typesanitizer
Type Bug
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Parser
Assignee None
Priority Medium

md5: b6e0e3b7b6cb09db588ec657fa874d07

Issue Description:

I would have expected the expected_rbrace_in_getset diagnostic to fire on missing a closing brace, but I don't see any test cases for it, and I can't figure out how to exercise that code path. Looks like the parsing code in parseGetSet doesn't recover gracefully in the presence of unbalanced braces. For example, the compiler trips up at the following two examples but it doesn't trigger expected_rbrace_in_getset :

struct S {
  var x : Int {
    get { 0
  }
}
// expected '}' in struct

and it also trips up on seeing other things:

struct T {
  var x : Int {
    get { 0
  }
  func f() {}
//^ expected 'get', 'set', 'willSet', or 'didSet' keyword to start an accessor definition
}

I understand that this is difficult to get right in the general case, but it would be nice to have a test case for the diagnostic, as well as have it fire more often.

@typesanitizer
Copy link
Author

@swift-ci create

@typesanitizer
Copy link
Author

I guess one simple way of trigger it is to not have a closing brace immediately after. But still, this needs some tests and arguably some better handling...

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 parser Area → compiler: The legacy C++ parser
Projects
None yet
Development

No branches or pull requests

1 participant