# An optional initializer was treated as definitive?!

**URL:** <https://forums.swift.org/t/an-optional-initializer-was-treated-as-definitive/85058>\
**Category:** Using Swift\
**Tags:** optional, initialisation\
**Created:** [March 1, 2026, 12:17am UTC](https://forums.swift.org/t/an-optional-initializer-was-treated-as-definitive/85058 "2026-03-01T00:17:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![CTMacUser](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ctmacuser/32/1802_2.png) [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Post date:** [March 1, 2026, 12:17am UTC](https://forums.swift.org/t/an-optional-initializer-was-treated-as-definitive/85058/1 "2026-03-01T00:17:01Z")

</div>

May be related to [this old post](https://forums.swift.org/t/treat-optional-as-non-optional-after-being-initialized/46931). This is from my testing code:

```swift
// Invalid should fail
//
// Replacing the second "initializer" with "NameToken" will make
// "digitStarter" to be `NameToken` _instead_ of `NameToken?`,
// but running the code crashes with an access-to-nil anyway(?!).
let initializer: (String) -> NameToken? = NameToken.init(_:)
let digitStarter = initializer("1startsWithDigit")
#expect(digitStarter == nil)

```

This tests the `LosslessStringConvertible` initializer, which is optional because not every potential string value is legal. I originally had “`#expect(NameToken(“1startsWithDigit“) == nil)`", but got warnings about a `nil` comparison isn’t needed against a definitive expression, although it isn’t actually definitive. Correctly, the code crashed with a nil-access error. From my note, any alternate that didn’t explicitly say that the return was `NameToken?` ended up as `NameToken` with a crash.

Huh?
