Skip to content

Diagnostic for static nonmutating should be improved #77835

Open
@AnthonyLatsis

Description

@AnthonyLatsis

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

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfdeclarationsFeature: declarationsdiagnostics QoIBug: Diagnostics Quality of Implementationgood first issueGood for newcomersmutatingFeature → declarations → functions: Mutating functionsstatic declarationsFeature → declarations: Static declarationsswift 6.1type checkerArea → compiler: Semantic analysis

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions