Swift 2b2: Compiler crashes on computed var in method of generic struct

Originator:rix.rob
Number:rdar://21669828 Date Originated:03-Jul-2015 10:09 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A121l)
Classification:Crash/Hang/Data Loss Reproducible:Always
 
Summary:
Subject summarizes symptoms sufficiently.

Steps to Reproduce:
This code:
struct S<T> {
	func f() -> String {
		var a: Int { return 0 }
		return "\(a)"
	}
}

Expected Results:
should not crash swiftc

Actual Results:
but totally does:

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-700.0.42.3/src/llvm/include/llvm/Support/Casting.h, line 237.

Regression:
- Doesn’t crash if the var isn’t inside a function/computed var.
- Doesn’t crash if the type isn’t generic.
- Does crash if you remove the return statement from the computed var (i.e. var a: Int { 0 })

Notes:
N/A

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!