-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-9043] Missing checks of inout/mutating captures #51546
Comments
Crash in master: $ cat test.swift
func run(_ body: @escaping () -> Void) { }
struct S {
var a: Int
mutating func foo() {
func _foo() {
_ = a
run { _foo() }
}
}
}
$ ../build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift test.swift
Applied argument must be @noescape function type: %11 = partial_apply [callee_guaranteed] %10(%0) : $@convention(thin) (@inout_aliasable S) -> () // users: %14, %13
A partial_apply with @inout_aliasable may only be used as a @noescape function type argument.
UNREACHABLE executed at /Users/rintaro/Repositories/swift-oss/swift/lib/SILOptimizer/Mandatory/DiagnoseStaticExclusivity.cpp:1078!
Stack dump:
0. Program arguments: /Users/rintaro/Repositories/swift-oss/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift -frontend -interpret test.swift -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name test
1. While running pass #​7 SILFunctionTransform "DiagnoseStaticExclusivity" on SILFunction "@$s4test1SV3fooyyF01_B0L_yyF".
for '_foo()' at test.swift:6:9
0 swift 0x000000010a44e2b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000010a44d288 llvm::sys::RunSignalHandlers() + 248
2 swift 0x000000010a44e8d2 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff6e3ceb3d _sigtramp + 29
4 swift 0x000000010b717678 llvm::dbgs()::thestrm + 16
5 libsystem_c.dylib 0x00007fff6e28d1c9 abort + 127
6 swift 0x000000010a3e14ee llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 542
7 swift 0x0000000107141d12 checkStaticExclusivity(swift::SILFunction&, swift::PostOrderFunctionInfo*, swift::AccessSummaryAnalysis*) + 13298
8 swift 0x000000010715e905 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1925
9 swift 0x000000010715fab3 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1299
10 swift 0x0000000107160bdf swift::SILPassManager::execute() + 607
11 swift 0x000000010673336b swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 187
12 swift 0x00000001071695b4 swift::runSILDiagnosticPasses(swift::SILModule&) + 132
13 swift 0x00000001065c01db performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 10923
14 swift 0x00000001065bc69d swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
15 swift 0x000000010656ea8e main + 686
16 libdyld.dylib 0x00007fff6e1e50a5 start + 1
Abort trap: 6 |
@swift-ci create |
Note that the closure { _foo } captures Hopefully, the fix for SR-8546 will cover this. SR-8546: Enforce @escaping for nested functions named inside conditional expressions. But the test case is sufficiently different that it should probably be two bugs. |
Environment
Xcode Version 10.0 (10A255)
Additional Detail from JIRA
md5: 23f0e6aa3983c486dcd3930dc0b1232d
relates to:
Issue Description:
The following code causes a compile-time error correctly.
However, when `run(_foo)` is changed to `run { _foo() }`, it can be compiled. I guess the compiler lacks some checks.
The text was updated successfully, but these errors were encountered: