Xcode6-Beta (6A215l): Swift REPL allows modification of let-declared constant value

Originator:mgorbach
Number:rdar://17224164 Date Originated:08-Jun-2014 12:04 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode6-Beta (6A215l)
Classification:Enhancement Reproducible:Always
 
Summary:
The Swift REPL lets you use inout parameters to change the value of a let-declared constant.

Steps to Reproduce:
Enter the following in the Swift REPL:

func testIncrement(inout b: Int) {
	b += 5
}

let x = 4
testIncrement(&x)
x

Actual Result:
x = 9

Expected Result:
Error. x should not be allowed to be modified because it should be a constant. In order for this code to run, x should have to be declared using “var.”

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!