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-14485] main compiler crash: GenericSignatureBuilder.cpp:8442: void checkGenericSignature(swift::CanGenericSignature, swift::GenericSignatureBuilder &): Assertion `isCanonicalAnchor(secondType)' failed #56840

Closed
weissi opened this issue Apr 14, 2021 · 2 comments
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 generics Feature: generic declarations and types

Comments

@weissi
Copy link
Member

weissi commented Apr 14, 2021

Previous ID SR-14485
Radar rdar://problem/76646764
Original Reporter @weissi
Type Bug
Status Resolved
Resolution Done
Environment

Swift version 5.5-dev (LLVM bcf6482631963a8, Swift 37aa203b753b23b)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Crash
Assignee None
Priority Medium

md5: d19231c42263e18d6f30726824d94f12

Issue Description:

The program from SR-14484 crashes the compiler (on main):

func truncate<Input: FixedWidthInteger & UnsignedInteger & BinaryInteger,
              Output: FixedWidthInteger & SignedInteger & BinaryInteger>(_ input: Input, outputType: Output.Type = Output.self) -> Output 
              where Output.Magnitude == Input {
    precondition(Output.Magnitude.self == Input.self)
    return Output(truncatingIfNeeded: input)
}

print(truncate(UInt(4), outputType: Int.self))

leads to

$ jw-docker-swift-main swift test.swift
docker.io/swiftlang/swift:nightly-main-bionic
test.swift:1:22: warning: redundant conformance constraint 'Input' : 'FixedWidthInteger'
func truncate<Input: FixedWidthInteger & UnsignedInteger & BinaryInteger,
                     ^
test.swift:2:23: note: conformance constraint 'Input' : 'FixedWidthInteger' implied here
              Output: FixedWidthInteger & SignedInteger & BinaryInteger>(_ input: Input, outputType: Output.Type = Output.self) -> Output 
                      ^
test.swift:1:42: warning: redundant conformance constraint 'Input' : 'UnsignedInteger'
func truncate<Input: FixedWidthInteger & UnsignedInteger & BinaryInteger,
                                         ^
test.swift:2:23: note: conformance constraint 'Input' : 'UnsignedInteger' implied here
              Output: FixedWidthInteger & SignedInteger & BinaryInteger>(_ input: Input, outputType: Output.Type = Output.self) -> Output 
                      ^
swift-frontend: /home/buildnode/jenkins/workspace/oss-swift-package-linux-ubuntu-18_04/swift/lib/AST/GenericSignatureBuilder.cpp:8442: void checkGenericSignature(swift::CanGenericSignature, swift::GenericSignatureBuilder &): Assertion `isCanonicalAnchor(secondType)' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0.  Program arguments: /usr/bin/swift-frontend -frontend -interpret test.swift -disable-objc-interop -color-diagnostics -module-name test
1.  Swift version 5.5-dev (LLVM bcf6482631963a8, Swift 37aa203b753b23b)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "test.swift")
3.  While type-checking 'truncate(_:outputType:)' (at test.swift:1:1)
4.  While evaluating request InterfaceTypeRequest(test.(file).truncate(_:outputType:)@test.swift:1:6)
5.  While evaluating request GenericSignatureRequest(test.(file).truncate(_:outputType:)@test.swift:1:6)
6.  While evaluating request InferredGenericSignatureRequest(test.test, NULL, test.(file).truncate(_:outputType:)@test.swift:1:6, {}, {(Input, Input), (Output.Type, Output.Type), (Output, Output)}, 0)
7.  While checking generic signature <τ_0_0, τ_0_1 where τ_0_0 == τ_0_0.Magnitude, τ_0_1 : FixedWidthInteger, τ_0_1 : SignedInteger, τ_0_0.Magnitude == τ_0_0.Magnitude.Magnitude.Magnitude> in requirement #&#8203;3
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
@weissi
Copy link
Member Author

weissi commented Apr 14, 2021

@swift-ci create

@slavapestov
Copy link
Member

#42113

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added CompilerCrash generics Feature: generic declarations and types labels Sep 17, 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 generics Feature: generic declarations and types
Projects
None yet
Development

No branches or pull requests

3 participants