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-11934] Segfault in TypeChecker::conformsToProtocol when using @autoclosure Any... #54353
Comments
Minimal reproducer func f(_ xs: @autoclosure Any...) { return }
f(0) Top of the stack trace when the crash happens: 4 swift 0x000000010f48e96f swift::TypeChecker::conformsToProtocol(swift::Type, swift::ProtocolDecl*
, swift::DeclContext*, swift::OptionSet<swift::ConformanceCheckFlags, unsigned int>, swift::SourceLoc) + 95
5 swift 0x000000010f27dd27 swift::constraints::ConstraintSystem::getPotentialBindings(swift::TypeVa
riableType*) + 11703 @swift-ci create |
As a work-around, you could use an array |
@swift-ci create |
Comment by David Hoerl (JIRA) theindigamer (JIRA User) Thanks for the workaround. I was playing with this as a future extension to something I use regularly (the code minus the autoclosure). I didn't think to reduce the error to the absolute minimum as you did - will work harder on future posts. |
I am surprised an [@autoclosure <type_name>] works - I thought we needed a function type as an argument to @ autoclosure? Variadic autoclosures were already banned long time ago, so this looks like a regression. I'll take a look! |
Here's a fix for the original problem: #28677 I've also found a different crash: func foo(_ closure: @autoclosure () -> String...) // gets diagnosed
foo("A") // but crashes here (although it shouldn't) I'll file a separate bug for this. The |
@theblixguy I just filed a bug for |
@hamishknight Thank you! I'll investigate that further, that seems to me like a more general problem with validating |
Fixed on master - please verify using the next available development snapshot! |
Resolved by #28819 dhoerl (JIRA User) Please use next available nightly snapshot of master to verify. |
Environment
Apple Swift version 5.1.2 (swiftlang-1100.0.278 clang-1100.0.33.9)
Target: x86_64-apple-darwin19.0.0
Save the above code in a file, then run it with "swift crash.swift"
Additional Detail from JIRA
md5: 6c5e153499d805f69d07a931d862ac5b
Issue Description:
The text was updated successfully, but these errors were encountered: