Skip to content

unused_parameter spurious violation for parameters used in calls to raw identifier functions whose name is a keyword, when prefixed with Swift 6.3 module selector #6816

Open

Description

@rgoldberg

New Issue Checklist

Bug Description

unused_parameter reports a spurious violation for parameters used in calls to a function whose name is the same as a keyword (achieved via raw identifiers) when, and only when, prefixed with a Swift 6.3 module selector:

Note: since module selectors are relatively new, there might be other bugs involving them.

func `as`(_: Int) {}
func `is`(_: Int) {}
func `a`(_: Int) {}

func violation(_ x: Int) { // violation: Parameter 'x' is unused
	Module::as(x)
	Module::is(x)
}

func noViolation1(_ x: Int) {
	Module::a(x)
}

func noViolation2(_ x: Int) {
	`as`(x)
}

func noViolation3(_ x: Int) {
	`is`(x)
}

func noViolation4(_ x: Int) {
	Module.as(x)
}

func noViolation5(_ x: Int) {
	Module.is(x)
}
$ swiftlint lint --only-rule unused_parameter Sources

Environment

  • SwiftLint version: 0.65.0
  • Xcode version: Xcode 26.6 / Build version 17F113
  • Installation method used: Homebrew
  • Configuration file: occurs without a config file

Are you using nested configurations?

No

Activity

  1. added
    bug
    swift-compiler
    on Jul 10, 2026
  2. SimplyDanny commented on Jul 10, 2026

    @SimplyDanny
    Collaborator

    Waiting for SwiftSyntax to support module selectors in combination with raw identifiers.

  3. rgoldberg commented on Jul 11, 2026

    @rgoldberg
    Author

    Has that been reported to Apple/SwiftLang? Is there any issue tracking for it or ETA for its completion?

    Thanks for any info.

  4. thliu21 commented on Jul 22, 2026

    @thliu21
    Contributor

    I could not find an existing upstream tracker, so I reproduced this against SwiftSyntax main as well as SwiftLint 0.65.0 and opened swiftlang/swift-syntax#3387.

    Module::as(x) and Module::is(x) are currently parsed as UnexpectedCodeDeclSyntax, so x never reaches unused_parameter as a reference. The mismatch is in atStartOfExpression(): it rejects the keyword after consuming the module selector even though parseDeclReferenceBase() supports that form.

    A small local parser fix plus regression tests passes all 19 ModuleSelectorTests. I will follow up with the upstream fix there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugswift-compiler

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions