You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swift-ci opened this issue
Dec 4, 2015
· 6 comments
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfIRGenLLVM IR generation
Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
XCode 7.1.1
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug, IRGen
Assignee
None
Priority
Medium
md5: 21024ad993e0d6972717c96c9ea9af7d
Issue Description:
Xcode and Playgrounds thinks this is valid code. Not until swiftc try to compile it the error is discovered. At that point it's not clear where the error is located as Xcode does not give any more information than the comment below. Playgrounds generates a crash log when communication is interrupted unexpectedly.
Checking protocol adherence of a subclass in a static function is not caught by linter and produces a really unhelpful error message. This should be caught and referenced by line of code where the error is located.
protocol ChildProt : class {
init()
func name() -> String
}
class Parent {
required init() {}
static func queryChildren() -> [ChildProt] {
// don't try to check a protocol adherence of self in a static function
guard let prot = self as? ChildProt else {
preconditionFailure()
}
return [prot.dynamicType.init()]
}
}
class Child : Parent, ChildProt {
var NAME = "John Doe"
required init() {}
func name() -> String {
return self.NAME
}
}
let child = Child.queryChildren().first!
child.name()
After hunting down the offending file, this is the error message produced by swiftc and presented in Xcode.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed!
%50 = phi i8** , !dbg !530
LLVM ERROR: Broken function found, compilation aborted!
Playground with example code attached
The text was updated successfully, but these errors were encountered:
This no longer crashes the compiler, but note that the code itself is invalid because its casting self in a static method (which is a metatype) to a protocol value. Fixed version:
protocol ChildProt : class {
init()
func name() -> String
}
class Parent {
required init() {}
static func queryChildren() -> [ChildProt] {
// don't try to check a protocol adherence of self in a static function
guard let prot = self as? ChildProt.Type else {
preconditionFailure()
}
return [prot.init()]
}
}
class Child : Parent, ChildProt {
var NAME = "John Doe"
required init() {}
func name() -> String {
return self.NAME
}
}
let child = Child.queryChildren().first!
child.name()
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler in itselfIRGenLLVM IR generation
Attachment: Download
Environment
Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
XCode 7.1.1
Additional Detail from JIRA
md5: 21024ad993e0d6972717c96c9ea9af7d
Issue Description:
Xcode and Playgrounds thinks this is valid code. Not until swiftc try to compile it the error is discovered. At that point it's not clear where the error is located as Xcode does not give any more information than the comment below. Playgrounds generates a crash log when communication is interrupted unexpectedly.
Checking protocol adherence of a subclass in a static function is not caught by linter and produces a really unhelpful error message. This should be caught and referenced by line of code where the error is located.
After hunting down the offending file, this is the error message produced by swiftc and presented in Xcode.
Playground with example code attached
The text was updated successfully, but these errors were encountered: