Skip to content

unneeded_escaping false positive when variable later used in a tuple #6621

Closed

Description

@rgoldberg

New Issue Checklist

Bug Description

unneeded_escaping false positive when variable later used in a tuple.

private import os

final class Lazy<Value: Sendable>: Sendable {
	private let state: OSAllocatedUnfairLock<(value: Value?, initializer: (@Sendable () -> Value)?)>

	var value: Value {
		state.withLock { state in
			state.value ?? {
				let value = state.initializer!() // swiftlint:disable:this force_unwrapping
				state.value = value
				state.initializer = nil
				return value
			}()
		}
	}

	init(_ initializer: @escaping @Sendable () -> Value) { // swiftlint:disable:this unneeded_escaping
		state = .init(initialState: (value: nil, initializer: initializer))
	}
}
swiftlint

Environment

  • SwiftLint version: 0.63.2
  • Xcode version: Xcode 26.4.1 / Build version 17E202
  • Installation method used: Homebrew
  • Configuration file:
only_rules:
  - unneeded_escaping

Are you using nested configurations? No

Activity

  1. self-assigned this
    on May 5, 2026
  2. added
    bug
    on May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions