Uploaded image for project: 'Swift'
  1. Swift
  2. SR-14485

main compiler crash: GenericSignatureBuilder.cpp:8442: void checkGenericSignature(swift::CanGenericSignature, swift::GenericSignatureBuilder &): Assertion `isCanonicalAnchor(secondType)' failed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
    • Environment:

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

      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 #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):
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            jw Johannes Weiss
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: