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-15038] Incorrect "conditional downcast from ... does nothing" diagnostic #57365
Comments
Also note that replacing Could not cast value of type 'Swift.Optional<Swift.String>' (0x7fff8170fd50) to 'Swift.String' (0x7fff81709120).
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode-13.0.0-Beta.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret file.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode-13.0.0-Beta.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.0.sdk -color-diagnostics -new-driver-path /Applications/Xcode-13.0.0-Beta.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -resource-dir /Applications/Xcode-13.0.0-Beta.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name file -target-sdk-version 12.0.0
1. Apple Swift version 5.5 (swiftlang-1300.0.27.6 clang-1300.0.27.2)
2.
3. While running user code "file.swift"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 swift-frontend 0x0000000113ba0187 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1 swift-frontend 0x0000000113b9f118 llvm::sys::RunSignalHandlers() + 248
2 swift-frontend 0x0000000113ba0796 SignalHandler(int) + 278
3 libsystem_platform.dylib 0x00007fff2056fd7d _sigtramp + 29
4 libsystem_malloc.dylib 0x00007fff2036bff4 _malloc_zone_calloc + 59
5 libsystem_c.dylib 0x00007fff2047f406 abort + 125
6 libswiftCore.dylib 0x00007fff2cbf37b5 swift::fatalError(unsigned int, char const*, ...) + 149
7 libswiftCore.dylib 0x00007fff2cbebb27 swift::swift_dynamicCastFailure(void const*, char const*, void const*, char const*, char const*) + 71
8 libswiftCore.dylib 0x00007fff2cbebb9a swift::swift_dynamicCastFailure(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, char const*) + 106
9 libswiftCore.dylib 0x00007fff2cbefecb swift_dynamicCast + 251
10 libswiftCore.dylib 0x00007fff2c8f1ba4 $ss15_arrayForceCastySayq_GSayxGr0_lF + 676
11 libswiftCore.dylib 0x00007fff2c8f0f7d _swift_arrayDownCastIndirect + 45
12 libswiftCore.dylib 0x00007fff2cbf0e88 tryCastToArray(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*&, swift::TargetMetadata<swift::InProcess> const*&, bool, bool) + 104
13 libswiftCore.dylib 0x00007fff2cbf01d5 tryCast(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*&, swift::TargetMetadata<swift::InProcess> const*&, bool, bool) + 565
14 libswiftCore.dylib 0x00007fff2cbf056f tryCast(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*&, swift::TargetMetadata<swift::InProcess> const*&, bool, bool) + 1487
15 libswiftCore.dylib 0x00007fff2cbefe6c swift_dynamicCast + 156
16 libswiftCore.dylib 0x0000000118fec797 swift_dynamicCast + 18446603344479766983
17 libswiftCore.dylib 0x0000000118fec18a swift_dynamicCast + 18446603344479765434
18 swift-frontend 0x000000010edc5e40 llvm::orc::runAsMain(int (*)(int, char**), llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::Optional<llvm::StringRef>) + 1408
19 swift-frontend 0x000000010ed26cb7 swift::RunImmediately(swift::CompilerInstance&, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, swift::IRGenOptions const&, swift::SILOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >&&) + 12839
20 swift-frontend 0x000000010ece5eac performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 2604
21 swift-frontend 0x000000010ecd7cae swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 14398
22 swift-frontend 0x000000010ec19718 main + 1032
23 libdyld.dylib 0x00007fff20545f3d start + 1
[1] 91009 abort DEVELOPER_DIR=/Applications/Xcode-13.0.0-Beta.4.app/Contents/Developer swift |
Here's a much smaller example:
|
I'll try take a look at this as well =] |
It depends. If the bug is that we're doing incorrect codegen because of something that was passed in incorrectly from sema, then the runtime is not really at fault for not doing the impossible. |
Sure, I'll try take a look soon to see what is happening |
Here is a PR #38884 theindigamer (JIRA User) After taking a look at it, I think this runtime issue could be another ticket, even if this is a Sema issue I think is not related to this incorrect warning problem. |
Fixed on main, @keith Can you please verify on the next available snapshot and close. Thanks 🙂 |
Sounds good, please feel free to file another ticket for the runtime issue and we can see who can work on it. |
Done theindigamer (JIRA User) SR-15082 =] |
Sorry for the confusion, my original point about how `as![]( |
Environment
% swift -version
swift-driver version: 1.26.7 Apple Swift version 5.5 (swiftlang-1300.0.27.6 clang-1300.0.27.2)
Target: arm64-apple-macosx11.0
Xcode 13.0 beta 4 (13A5201i)
Additional Detail from JIRA
md5: d316ac620e0645b1843c3a363229a922
relates to:
Issue Description:
With this code:
You get this warning:
Which is invalid because `[Any] as? [T.Element]` does not do nothing, it will return `nil` in this example because `[Any] as? [String]` for `["x", 1]` will not cast.
The text was updated successfully, but these errors were encountered: