다음 코드는 WWDC의 중급 스위프트 토크 예제에서 파생 된 것입니다. 내가 뭘하려고하는지 API 클래스의 일종에서 온 키 속성 목록에서 모델 클래스를 초기화하는 것입니다. 나는이 컴파일 할 때스위프트 스위치 케이스 컴파일러 오류
class Movie {
var title: String
init(title: String) {
self.title = title
}
}
func movieFromDictionary(dict: Dictionary<String, AnyObject>) -> Movie? {
switch dict["title"] {
case .Some(let movieTitle as String):
return Movie(title: movieTitle)
default:
return nil
}
}
, 나는 다음과 같은 오류가 발생합니다 :
Bitcast requires both operands to be pointer or neither
%38 = bitcast i8* %37 to %SS, !dbg !161
Invalid operand types for ICmp instruction
%39 = icmp ne %SS %38, null, !dbg !161
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed!
%42 = phi i64 , !dbg !161
PHI node operands are not the same type as the result!
%41 = phi i8* [ %38, %34 ], !dbg !161
LLVM ERROR: Broken function found, compilation aborted!
Command /Applications/Xcode6-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift failed with exit code 1
흥미롭게 편집기 코드로 확인 될 것으로 보인다. 이것은 컴파일러 버그 또는 코드에 문제가 있습니까?
이것은 확실히 컴파일러 버그입니다. – rightfold
코드가 맞는지 여부에 관계없이 이것은 컴파일러 버그입니다. 컴파일러는 코드를 분석하고 코드가 올바른지 아닌지를 결정할 수 있어야합니다. 잘못된 코드 일 경우 오류를 발생 시키거나 올바른 경우 유효한 코드를 생성 할 수 있어야합니다. 이 경우에는 올바른 것으로 결정한 다음 __invalid__ 낮은 수준의 코드가 생성되어서는 안됩니다. 사과에게이 사실을보고해야합니다. –