Swift REPL allows changing of constants
| Originator: | ole.begemann | ||
| Number: | rdar://17163771 | Date Originated: | 2014-06-05 |
| Status: | Resolved | Resolved: | 2014-06-27 |
| Product: | Developer Tools | Product Version: | Xcode 6 Beta 1 (6A215l) |
| Classification: | Serious Bug | Reproducible: | Always |
Note: This issue is resolved in Xcode 6 Beta 2. Summary: The Swift REPL incorrectly allows you to change a constant defined with "let". Steps to Reproduce: 1. Launch the Swift REPL from the command line: $ xcrun swift Welcome to Swift! Type :help for assistance. 2. Define a constant: 1> let a = 5 a: Int = 5 3. Try to assign a new value to a: 2> a = 10 Expected Results: I expect the REPL to show an error because assigning to constants is not allowed. Actual Results: There is no error. The value appears to have changed: 3> println(a) 10 Version: Xcode Version 6.0 (6A215l) OS X 10.9.3 (13D65) $ xcrun swift --version Swift version 1.0 (swift-600.0.34.4.5) Target: x86_64-apple-darwin13.2.0 Notes: Note that this bug only appears when you launch the REPL without the "-integrated-repl" argument. When launched with "-integrated-repl", it behaves correctly: $ xcrun swift -integrated-repl Welcome to swift. Type ':help' for assistance. (swift) let a = 5 // a : Int = 5 (swift) a = 10 <REPL Input>:1:3: error: cannot assign to 'let' value 'a' a = 10 ~ ^ Discussed in the Dev Forums at https://devforums.apple.com/message/971654#971654.
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!