swiftlang/swift

Diagnostic for `static nonmutating` should be improved

開放

#77,835 建立於 2024年11月25日

 (11 則留言) (0 個反應) (1 位負責人)Swift (10,719 個分叉)batch import
bugcompilerdeclarationsdiagnostics qualitygood first issuemutatingstatic declarationsswift 6.1type checker

倉庫指標

星標
 (69,989 顆星)
PR 合併指標
 (平均合併 8天 17小時) (30 天內合併 510 個 PR)

描述

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 (26e888e45e6ede4)

Additional information

No response

貢獻者指南