May be related to this old post. This is from my testing code:
// 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?