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

Disallow `@convention(c)` and `@autoclosure` parameters

    XMLWordPrintable

    Details

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

      DEVELOPMENT-SNAPSHOT-2019-06-23-a
      Apple Swift version 5.1-dev (LLVM af1f73e9e9, Swift bcdd46cdfe)
      Target: x86_64-apple-darwin18.6.0

      Description

      @convention(c) and @autoclosure parameters should be rejected during type checking.
      Currently, the compiler crashes during SILGen:

      func foo(_ f: @convention(c) @autoclosure () -> Int) -> Void {}
      foo(1)
      
      Assertion failed: (expectedFnType->getExtInfo().hasContext() && "conversion thunk will not be thin!"), function transformFunction, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SILGen/SILGenPoly.cpp, line 3361.
      Stack dump:
      0.	Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-06-23-a.xctoolchain/usr/bin/swift -frontend -interpret sr-11027.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name main
      1.	Apple Swift version 5.1-dev (LLVM af1f73e9e9, Swift bcdd46cdfe)
      0  swift                    0x000000010392e7f5 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
      1  swift                    0x000000010392dae5 llvm::sys::RunSignalHandlers() + 85
      2  swift                    0x000000010392edd8 SignalHandler(int) + 264
      3  libsystem_platform.dylib 0x00007fff5f922b5d _sigtramp + 29
      4  libsystem_platform.dylib 0x0000000114fd1938 _sigtramp + 3043683832
      5  libsystem_c.dylib        0x00007fff5f7dc6a6 abort + 127
      6  libsystem_c.dylib        0x00007fff5f7a520d basename_r + 0
      7  swift                    0x0000000103ab9f73 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) (.cold.4) + 35
      8  swift                    0x000000010045dc6b (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 12395
      9  swift                    0x000000010045a477 swift::Lowering::SILGenFunction::emitOrigToSubstValue(swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 215
      10 swift                    0x0000000100424b02 swift::Lowering::SILGenFunction::emitClosureValue(swift::SILLocation, swift::SILDeclRef, swift::CanType, swift::SubstitutionMap) + 1042
      11 swift                    0x000000010041acb5 (anonymous namespace)::RValueEmitter::visitAbstractClosureExpr(swift::AbstractClosureExpr*, swift::Lowering::SGFContext) + 229
      12 swift                    0x000000010040d635 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 133
      13 swift                    0x0000000100403126 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 54
      14 swift                    0x00000001003c1508 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1960
      15 swift                    0x00000001003b0526 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 70
      16 swift                    0x00000001003cb6d3 (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 147
      17 swift                    0x00000001003cb48c (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus) && + 684
      18 swift                    0x00000001003cae2b (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::CanTypeWrapper<swift::FunctionType>&, swift::Lowering::AbstractionPattern&, swift::CanTypeWrapper<swift::SILFunctionType>, llvm::Optional<swift::ForeignErrorConvention> const&, swift::ImportAsMemberStatus, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&, swift::CanTypeWrapper<swift::FunctionType>&) + 1675
      19 swift                    0x00000001003b34a4 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2948
      20 swift                    0x00000001003b2884 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2404
      21 swift                    0x000000010040d61e swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 110
      22 swift                    0x0000000100403621 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 1137
      23 swift                    0x00000001003a93b4 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 580
      24 swift                    0x00000001003a9896 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) + 822
      25 swift                    0x00000001003aa859 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*) + 361
      26 swift                    0x00000001003aac10 swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&) + 16
      27 swift                    0x00000001000d85c2 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 9586
      28 swift                    0x00000001000d5071 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3025
      29 swift                    0x000000010007d509 main + 729
      30 libdyld.dylib            0x00007fff5f7373d5 start + 1
      [1]    95601 abort      swift sr-11027.swift
      

      Consider disallowing other @convention + autoclosure combinations.

        Attachments

          Activity

            People

            • Assignee:
              danzheng Dan Zheng
              Reporter:
              danzheng Dan Zheng
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: