Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11027] Disallow @convention(c) and @autoclosure parameters #53417

Closed
dan-zheng opened this issue Jun 27, 2019 · 3 comments
Closed

[SR-11027] Disallow @convention(c) and @autoclosure parameters #53417

dan-zheng opened this issue Jun 27, 2019 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis

Comments

@dan-zheng
Copy link
Collaborator

Previous ID SR-11027
Radar None
Original Reporter @dan-zheng
Type Bug
Status Resolved
Resolution Done
Environment

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

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @dan-zheng
Priority Medium

md5: f11e7d4d622033b892399ac682af75f2

Issue 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.

@LucianoPAlmeida
Copy link
Collaborator

@dan-zheng this seems like a good starter task, if there's no one working on that yet could I assign myself to it?

@dan-zheng
Copy link
Collaborator Author

@LucianoPAlmeida Please go ahead!

@LucianoPAlmeida
Copy link
Collaborator

Here's the PR #27078

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants