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

Runtime crash demangling associated type for type defined in equality-constrained extension

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Environment:

      macOS Catalina

      MacBook Pro (15-inch, 2017)

      Xcode 11 Version 11.1 (11A1027)

      Description

      I found a runtime crash when running the following code (e.g. in a playground):

      // MARK: Types
      
      
      struct Validator<T> {
          let validatorFailureType: Any.Type
      }
      
      
      protocol ValidatorType {
          associatedtype Data
          associatedtype Failure
          func validator() -> Validator<Data>
      }
      
      
      extension ValidatorType {
          func validator() -> Validator<Data> {
              .init(validatorFailureType: Failure.self)
          }
      }
      
      
      // MARK: Failing example
      
      
      extension Validator where T == String {
          struct V: ValidatorType {
              typealias Data = T // or String
              struct Failure {}
          }
      }
      
      
      Validator.V().validator() // failed to demangle witness for associated type 'Failure' in conformance '(extension in __lldb_expr_1):__lldb_expr_1.Validator<Swift.String>.V4: ValidatorType' from mangled name '13__lldb_expr_19ValidatorVAASSRszrlE2V4V7FailureVyx__G'
      

       
      I attached a playground file that contains a few similar but non-crashing examples.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            siemensikkema Siemen
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: