Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-7101] Compiler crash when implementing a protocol for an enum using generics #49649

Closed
swift-ci opened this issue Mar 1, 2018 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 1, 2018

Previous ID SR-7101
Radar None
Original Reporter lmz (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Linux, swift 4.1 Development Ubuntu 16.10 snapshot from 2018-02-28.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @hamishknight
Priority Medium

md5: 456fc4af50fe6b00c96809b349496e6c

Issue Description:

I got an assertion failure when trying to compile some code involving an extension for an enum using generics. It seems that the typealias is also necessary as I don't get any error when removing it.

The failed assertion is in include/swift/AST/Type.h "Forming a CanType out of a non-canonical type!"' failed.

public enum V {
  case v(Float)
}

public typealias Valias = V

extension V : ExpressibleByFloatLiteral {
  public init(floatLiteral value: Float) {
    self = .v(value)
  }
}

public enum G<T> {
  case g(T)
}

extension G : ExpressibleByFloatLiteral where T == Valias {
  public typealias FloatLiteralType = Valias.FloatLiteralType
  public init(floatLiteral value: FloatLiteralType) {
    self = .g(Valias.init(floatLiteral: value))
  }
}

Here is the output that I got:

Swift version 4.1-dev (LLVM 1c8b50929b, Clang 420ae40df6, Swift 7ebaa8a966)
Target: x86_64-unknown-linux-gnu
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift -frontend -c -primary-file a.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name a -o /tmp/a-875ce5.o
swift: /home/buildnode/jenkins/workspace/oss-swift-4.1-package-linux-ubuntu-16_10/swift/include/swift/AST/Type.h:393: swift::CanType::CanType(swift::Type): Assertion `isActuallyCanonicalOrNull() && "Forming a CanType out of a non-canonical type!"' failed.
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x3f2e104]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x3f2e446]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7f1b333cb0c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7f1b31b38fcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f1b31b3a3fa]
/lib/x86_64-linux-gnu/libc.so.6(+0x2be37)[0x7f1b31b31e37]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bee2)[0x7f1b31b31ee2]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x571ecc]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x4e7750]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x5af3fa]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x5afbe7]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x4c4c67]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x4c046c]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x478234]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7f1b31b262b1]
swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift[0x475aea]
Stack dump:
0.  Program arguments: swift-4.1-DEVELOPMENT-SNAPSHOT-2018-02-28-a-ubuntu16.10/usr/bin/swift -frontend -c -primary-file a.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name a -o /tmp/a-875ce5.o 
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)
@hamishknight
Copy link
Collaborator

#14928

@hamishknight
Copy link
Collaborator

Resolved in the above linked pull request. lmz (JIRA User) can you please try with a future development snapshot (it should make it into 3rd March 2018) and then mark the issue as closed if satisfied?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 4, 2018

Comment by Laurent Mazare (JIRA)

All good with the latest trunk snapshot from 2017-03-03. Thanks for the quick fix!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants