Skip to content

Ignore comment doesn't apply to a subscript when on its first line #1113

@rgoldberg

Description

@rgoldberg

Describe the bug

An ignore comment (// periphery:ignore) doesn't apply to a subscript when on its first line.

Here's a contrived example:

// ignore comment works here
extension String { // ignore comment doesn't work here; IMHO, it should
	subscript(_: Int) -> Self {
		self
	} // ignore comment works here
}

Reproduction

extension String { // periphery:ignore
	subscript(_: Int) -> Self {
		self
	}
}
$ periphery scan
… warning: Unused function 'subscript(_:)'

Environment

$ periphery version
3.7.2
$ swift -version
swift-driver version: 1.148.6 Apple Swift version 6.3 (swiftlang-6.3.0.123.5 clang-2100.0.123.102)
Target: arm64-apple-macosx26.0
$ xcodebuild -version
Xcode 26.4
Build version 17E192

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions