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

Type checker crash-on-invalid

    XMLWordPrintable

    Details

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

      Description

      Compile:

      extension MutableCollection {
        public mutating func writePrefix<I: IteratorProtocol>(from source: inout I)
          -> (writtenCount: Int, afterLastWritten: Index)
          where I.Element == Element
        {
          fatalError()
        }
        
        public mutating func writePrefix<Source: Collection>(from source: Source)
          -> (writtenCount: Int, afterLastWritten: Index, afterLastRead: Source.Index)
          where Source.Element == Element
        {
          fatalError()
        }
      
      }
      
      func testWritePrefixIterator() {
        var a = Array(0..<10)
        
        var underflow = (1..<10).makeIterator()
        var (writtenCount, afterLastWritten) = a.writePrefix(from: underflow)
      }
      
      0.	Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file x.swift -target x86_64-apple-darwin19.6.0 -enable-objc-interop -stack-check -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -target-sdk-version 11.0 -module-name x -o /var/folders/z0/4612twmx5wbfrsp0jxbcvwrm00qbwx/T/x-69a4f6.o 
      1.	Apple Swift version 5.3 (swiftlang-1200.0.28.1 clang-1200.0.30.1)
      2.	While evaluating request TypeCheckSourceFileRequest(source_file "x.swift")
      3.	While evaluating request TypeCheckFunctionBodyUntilRequest(x.(file).testWritePrefixIterator()@x.swift:18:8, )
      4.	While type-checking statement at [x.swift:18:34 - line:23:3] RangeText="{
          var a = Array(0..<10)
          
          var underflow = (1..<10).makeIterator()
          var (writtenCount, afterLastWritten) = a.writePrefix(from: underflow)
        "
      5.	While type-checking declaration 0x7fec7703dc70 (at x.swift:22:5)
      6.	While evaluating request PatternBindingEntryRequest((unknown decl), 0)
      7.	While type-checking expression at [x.swift:22:44 - line:22:73] RangeText="a.writePrefix(from: underflow"
      0  swift                    0x0000000109f64a85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1  swift                    0x0000000109f63a85 llvm::sys::RunSignalHandlers() + 85
      2  swift                    0x0000000109f6503f SignalHandler(int) + 111
      3  libsystem_platform.dylib 0x00007fff67c7a5fd _sigtramp + 29
      4  swift                    0x00000001068bec1f swift::Type llvm::function_ref<swift::Type (swift::TypeVariableType*)>::callback_fn<swift::constraints::ConstraintSystem::simplifyType(swift::Type) const::$_18>(long, swift::TypeVariableType*) + 47
      5  swift                    0x000000010680de64 swift::constraints::ConstraintSystem::simplifyFixConstraint(swift::constraints::ConstraintFix*, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 2628
      6  swift                    0x00000001067fb0ce swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 15134
      7  swift                    0x00000001068216f7 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 2119
      8  swift                    0x000000010682cd31 swift::constraints::ConstraintSystem::simplify(bool) + 145
      9  swift                    0x0000000106842232 swift::constraints::DisjunctionStep::attempt(swift::constraints::DisjunctionChoice const&) + 178
      10 swift                    0x0000000106841a8c swift::constraints::BindingStep<swift::constraints::DisjunctionChoiceProducer>::take(bool) + 540
      11 swift                    0x0000000106841855 swift::constraints::DisjunctionStep::resume(bool) + 821
      12 swift                    0x000000010682ece7 swift::constraints::ConstraintSystem::solveImpl(llvm::SmallVectorImpl<swift::constraints::Solution>&) + 311
      13 swift                    0x00000001068b1519 swift::constraints::ConstraintSystem::salvage() + 185
      14 swift                    0x000000010683134d swift::constraints::ConstraintSystem::solve(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 1821
      15 swift                    0x000000010696ed5f swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 799
      16 swift                    0x00000001069704d7 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*, swift::Type, swift::PatternBindingDecl*, unsigned int) + 151
      17 swift                    0x00000001069706c0 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int, swift::Type) + 256
      18 swift                    0x0000000106a59006 swift::PatternBindingEntryRequest::evaluate(swift::Evaluator&, swift::PatternBindingDecl*, unsigned int) const + 550
      19 swift                    0x000000010699faa9 llvm::Expected<swift::PatternBindingEntryRequest::OutputType> swift::Evaluator::getResultUncached<swift::PatternBindingEntryRequest>(swift::PatternBindingEntryRequest const&) + 777
      20 swift                    0x0000000106991a77 swift::PatternBindingEntryRequest::OutputType swift::evaluateOrDefault<swift::PatternBindingEntryRequest>(swift::Evaluator&, swift::PatternBindingEntryRequest, swift::PatternBindingEntryRequest::OutputType) + 55
      21 swift                    0x00000001069c5a1f (anonymous namespace)::DeclChecker::visit(swift::Decl*) + 5007
      22 swift                    0x0000000106a53ca7 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 8695
      23 swift                    0x0000000106a4f69a bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 314
      24 swift                    0x0000000106a4e0a7 swift::TypeCheckFunctionBodyUntilRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*, swift::SourceLoc) const + 2231
      25 swift                    0x0000000106a56e7d llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyUntilRequest, (void*)0>(swift::TypeCheckFunctionBodyUntilRequest const&) + 925
      26 swift                    0x0000000106a4f148 swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 440
      27 swift                    0x0000000106a8ca84 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 1380
      28 swift                    0x0000000106a8f699 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 953
      29 swift                    0x0000000106a8c394 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 164
      30 swift                    0x0000000105c07a07 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 6439
      31 swift                    0x0000000105ac896d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6845
      32 swift                    0x0000000105a4d277 main + 1255
      33 libdyld.dylib            0x00007fff67a81cc9 start + 1
      34 libdyld.dylib            0x0000000000000011 start + 18446603338777092937
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dabrahams Dave Abrahams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: