Swift classes declared inside function that access variables from their outer scope crash the compiler

Originator:alex
Number:rdar://19983226 Date Originated:27-Feb-2015 12:14 PM
Status:Duplicate/18998859 Resolved:
Product:Developer Tools Product Version:
Classification:Crash Reproducible:Always
 
Summary:
Consider the following code:
class OuterClass {
	func outerMethod() {
		let value = 4
		class InnerClass {
			func innerMethod() {
				println("\(value)")
			}
		}
		let connector = InnerClass()
		connector.innerMethod()
	}
}

The class InnerClass is declared inside a function and method innerMethod tries to access a variable that is declared inside the function itself. Trying to compile the code results crashes the compiler with "Segmentation fault: 11"

Steps to Reproduce:
1. Open the sample project or create a new project with the code as described in the description
2. Try to compile it

Expected Results:
The compiler should either issue an error declaring that accessing variables of a class’s outer scope is prohibited in Swift or should compile fine with the class being able to access the variable

Actual Results:
The compiler crashes with "Segmentation fault: 11"

Version:
Xcode 6.1.1 (6A2008a) and Xcode 6.3 (6D532l)
OS X Yosemite 10.10.2 (14C109)

Notes:


Configuration:
Xcode 6.1.1 (6A2008a) and Xcode 6.3 (6D532l)
OS X Yosemite 10.10.2 (14C109)

Attachments:
'OuterScopeError.zip' was successfully uploaded.

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!