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

Diagnostic for static nonmutating should be improved #77835

Open
AnthonyLatsis opened this issue Nov 25, 2024 · 5 comments · May be fixed by #78052
Open

Diagnostic for static nonmutating should be improved #77835

AnthonyLatsis opened this issue Nov 25, 2024 · 5 comments · May be fixed by #78052
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself declarations Feature: declarations diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers mutating Feature → declarations → functions: Mutating functions static declarations Feature → declarations: Static declarations swift 6.1 type checker Area → compiler: Semantic analysis

Comments

@AnthonyLatsis
Copy link
Collaborator

Description

No response

Reproduction

struct S {
  nonmutating static func foo() {}
}
430 | 
431 | struct S {
432 |   nonmutating static func foo() {}
    |   `- error: static functions must not be declared mutating [static_functions_not_mutating]
433 | }
434 | 

Expected behavior

An example approach to improving this error message is to list both modifiers.

We can also tailor it to call out the modifier in question as it currently does in the case of mutating. The drawback of this option is that it conveys less information about language grammar.s

Environment

Swift version 6.1-dev (26e888e)

Additional information

No response

@AnthonyLatsis AnthonyLatsis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself good first issue Good for newcomers diagnostics QoI Bug: Diagnostics Quality of Implementation type checker Area → compiler: Semantic analysis declarations Feature: declarations static declarations Feature → declarations: Static declarations mutating Feature → declarations → functions: Mutating functions swift 6.1 labels Nov 25, 2024
@zvyaan
Copy link

zvyaan commented Nov 28, 2024

Hi there,

I'd like to be assigned this issue, will try to work on it soon!

@devnumber7
Copy link

Hello,

I would like to work on it as my first issue !

@vlkhvnn
Copy link

vlkhvnn commented Dec 24, 2024

Hello, I would like to work on this issue as my first one, very excited!

@AnthonyLatsis
Copy link
Collaborator Author

Hi folks, this issue is already assigned.

@AnthonyLatsis
Copy link
Collaborator Author

You might also like #78362.

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 itself declarations Feature: declarations diagnostics QoI Bug: Diagnostics Quality of Implementation good first issue Good for newcomers mutating Feature → declarations → functions: Mutating functions static declarations Feature → declarations: Static declarations swift 6.1 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants