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

Implement tuple conversion

    XMLWordPrintable

    Details

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

      Xcode 8 (8A218a)
      Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)
      Build Target iOS SDK 10

      Description

      Compiler crashes when trying to compile the following code:

      class ViewController: UIViewController {
      
          override func viewDidLoad() {
              super.viewDidLoad()
              
              // this works:
              let tapAction: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(optionTapped(_:)))
              let items: [(String, UIGestureRecognizer)] = [("Action", tapAction)]
              dump(tapAction)
              dump(items)
          }
          
          // this works
          let items1: [(String, UIGestureRecognizer)] = {
              let tapAction: UIGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(optionTapped(_:)))
              let items = [("Action", tapAction)]
              return items
          }()
      
          // this causes segfault
          let items2: [(String, UIGestureRecognizer)] = {
              let tapAction: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(optionTapped(_:)))
              let items = [("Action", tapAction)]
              return items
          }()
          
          func optionTapped(_ sender: UIGestureRecognizer?) {
              dump(sender)
          }
      
      }
      

      This is the segfault output:

      <unknown>:0: error: cannot express tuple conversion '(String, UITapGestureRecognizer)' to '(String, UIGestureRecognizer)'
      0  swift                    0x000000010cc7ab6d PrintStackTraceSignalHandler(void*) + 45
      1  swift                    0x000000010cc7a5b6 SignalHandler(int) + 470
      2  libsystem_platform.dylib 0x00007fff9576e52a _sigtramp + 26
      3  libsystem_platform.dylib 0x00007fff55bdbd48 _sigtramp + 3225868344
      4  swift                    0x000000010a9ed02e swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 5438
      5  swift                    0x000000010a8f1eac swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 3020
      6  swift                    0x000000010a973bb2 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 6114
      7  swift                    0x000000010a972516 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 326
      8  swift                    0x000000010a97667b swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 267
      9  swift                    0x000000010a8f1a1b swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1851
      10 swift                    0x000000010a8f3fdc swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 300
      11 swift                    0x000000010a8f4903 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 579
      12 swift                    0x000000010a9023a2 (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 3938
      13 swift                    0x000000010a90294b (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 5387
      14 swift                    0x000000010a91dbf4 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 180
      15 swift                    0x000000010a92935a swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1866
      16 swift                    0x000000010a5dfaab swift::CompilerInstance::performSema() + 5643
      17 swift                    0x000000010a08c00d performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2765
      18 swift                    0x000000010a089265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
      19 swift                    0x000000010a04682d main + 8685
      20 libdyld.dylib            0x00007fff881b65ad start + 1
      Stack dump:
      (...)
      1.  While type-checking 'ViewController' at SwiftCrash/ViewController.swift:11:1
      2.  While type-checking expression at [SwiftCrash/ViewController.swift:31:51 - line:35:7] RangeText="{
              let tapAction: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(optionTapped(_:)))
              let items = [("Action", tapAction)]
              return items
          }()"
      3.  While type-checking expression at [SwiftCrash/ViewController.swift:34:16 - line:34:16] RangeText="i"
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                slavapestov Slava Pestov
                Reporter:
                paul.eipper Paul Eipper
              • Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: