Property optional is not initialized to nil by default
| Originator: | valerio.ferrucci | ||
| Number: | rdar://17744181 | Date Originated: | 21/7/2014 |
| Status: | Open | Resolved: | No |
| Product: | Swift | Product Version: | 1 |
| Classification: | Reproducible: | Yes |
Steps to Reproduce:
1. Create a new iOS "Single View Application" Project in XCode 6 Beta 3
2. View Controller.swift code:
import UIKit
class ViewController: UIViewController {
let user : User = User()
}
3. File User.swift code:
import Foundation
class User {
var name : String?
}
Expected Results:
Compilation successfull
Actual Results:
Compilation error:
"User is not constructible with ()"
Version:
XCode 6.0 6A254o (Beta 3)
Notes:
Guthub sample project:
https://github.com/valfer/OptionalBug
Stack overflow:
http://stackoverflow.com/questions/24807074/swift-optional-property-error
Apple Developer Forum: https://devforums.apple.com/message/1007646#1007646
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!