You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
redundant_optional_initialization warns on wrapped nilable property leading to compile errors #3998
@propertyWrapperstructWrapper<T>{letname:StringvarwrappedValue:Tinit(wrappedValuevalue:T,_name:String){self.name=nameself.wrappedValue=value}}structWrapped{@Wrapper("name")varflag:Bool?=nil // redundant_optional_initialization warns here
}
SwiftLint warns on the wrapped property assigned to nil. The property wrapper requires this explicit initialization, however. Removing the explicit assignment leads to a compile error.
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint main.swift
Linting Swift files at paths main.swift
Linting 'main.swift' (1/1)
main.swift:14:20: warning: Redundant Optional Initialization Violation: Initializing an optional variable with nil is redundant. (redundant_optional_initialization)
Done linting! Found 1 violation, 0 serious in 1 file.
Activity
theamodhshetty commentedon Feb 27, 2026
I opened a PR for this: #6513
Implemented a targeted fix via configuration instead of globally skipping annotated properties:
ignore_attributestoimplicit_optional_initializationstyle: always, declarations with ignored attributes are skippedThis keeps current defaults unchanged while allowing wrapper-specific opt-outs (e.g. wrappers that require explicit
= nil).