test.swift:15:25: error: cannot perform mutating operation: 'self.s' is a 'let' constant
self.s.delegate = self
^
test.swift:12:5: note: change 'let' to 'var' to make it mutable
let s: Sample = SampleA()
^~~
var
I can see why this was allowed before, since the let constant doesn't need to be guaranteed to be fully initialized until after init has completed.
The text was updated successfully, but these errors were encountered:
benasher44 (JIRA User), note that if you make Sample class-constrained as well the problem goes away. As written, the error is arguably correct, since setting anything on a let property, ever, would be invalid if it might be a value type.
That makes sense
Environment
macOS Sierra 10.12.3
Xcode 8.2.1 (App Store version)
Swift 3.1 snapshot: 3.1-DEVELOPMENT-SNAPSHOT-2017-02-11-a
Additional Detail from JIRA
md5: 7117b5bd4615c0cd1a5a3e3e77ecfedd
Issue Description:
The following code works fine in Swift 3 (3.0.2) but generates an error in Swift 3.1:
Here is the generated error:
I can see why this was allowed before, since the let constant doesn't need to be guaranteed to be fully initialized until after init has completed.
The text was updated successfully, but these errors were encountered: