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-11265] Imperfect error message when using both 'static' and 'class' for a single func #53666

Closed
swift-ci opened this issue Aug 7, 2019 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Aug 7, 2019

Previous ID SR-11265
Radar None
Original Reporter cukier (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 5.1 (swiftlang-1100.0.257.2 clang-1100.0.31.3)
Target: x86_64-apple-darwin18.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, DiagnosticsQoI, StarterBug
Assignee cukier (JIRA)
Priority Medium

md5: 499264e4b5a66e69cbb00c0e4ef2f4b6

Issue Description:

When you accidentally write `static class func` it complains about writing `class` twice, even though you wrote it once. I would've expected something like "impossible for func to be 'static' and 'class' at the same time". Similar error exists with vars

To reproduce:

class Foo {
  class static func baz() { }
  static class func bar() { }
  class static var a: Int { 123 }
  static class var b: Int { 123 }
} 

Will output

test.swift:2:9: error: 'static' specified twice
  class static func baz() { }
  ~~~~~ ^~~~~~~

test.swift:3:10: error: 'class' specified twice
  static class func bar() { }
  ~~~~~~ ^~~~~~

test.swift:4:9: error: 'static' specified twice
  class static var a: Int { 123 }
  ~~~~~ ^~~~~~~

test.swift:5:10: error: 'class' specified twice
  static class var b: Int { 123 }
  ~~~~~~ ^~~~~~
@theblixguy
Copy link
Collaborator

I suppose the diagnostic can be updated to say "%0 cannot appear nested inside another 'static' or 'class' pattern", like we do for let/var. What do you think @xedin?

@LucianoPAlmeida
Copy link
Collaborator

Maybe use 'modifier' term instead of 'pattern' @theblixguy?
Also, should this be labeled as starter bug?

@zoecarver
Copy link
Collaborator

Can I take this one? It looks like a good first issue.

@LucianoPAlmeida
Copy link
Collaborator

Since the PR is merged should this be resolved?

@xedin
Copy link
Member

xedin commented Aug 28, 2019

It should be since PR has been merged. Please use the latest master snapshot to verify and close.

@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 diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

5 participants