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-5177] Observing keypath for non-objc type crashes with misleading error message #4087

Closed
swift-ci opened this issue Jun 9, 2017 · 1 comment

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Jun 9, 2017

Previous ID SR-5177
Radar rdar://problem/32775952
Original Reporter tgoyne (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Xcode 9 beta 1 on macOS 10.12.5.

Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug
Assignee None
Priority Medium

md5: 23229b67e8170c9124982d4eda2fb642

duplicates:

  • SR-5115 KeyPath-based KVO: No diagnostic for inaccessible KVO KeyPaths

Issue Description:

The following code:

import Foundation

class Test: NSObject {
    let value: Int? = nil
}

var obj = Test()
let _ = obj.observe(\.value) { _, _ in }

crashes with the following message:

fatal error: Could not extract a String from KeyPath Swift.WritableKeyPath<test.Test, Swift.Optional<Swift.Int>>: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.43/src/swift/stdlib/public/SDK/Foundation/NSObject.swift, line 85
0  swift                    0x00000001077fe3aa PrintStackTraceSignalHandler(void*) + 42
1  swift                    0x00000001077fd7e6 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffd5536b3a _sigtramp + 26
3  libsystem_platform.dylib 000000000000000000 _sigtramp + 715953376
4  libswiftFoundation.dylib 0x000000010d643972 _T010Foundation26_KVOKeyPathBridgeMachinery33_6DA0945A07226B3278459E9368612FF4LLC010_bridgeKeyC0SSs03AnylC0CFZTf4gd_n + 594
5  libswiftFoundation.dylib 0x000000010d5aad61 _T010Foundation27_KeyValueCodingAndObservingPAAE7observeAA05NSKeyC11ObservationCs0B4PathCyxqd__G_So0hcF7OptionsV7optionsyx_AA0hC14ObservedChangeVyqd__Gtc13changeHandlertlF + 321
6  libswiftFoundation.dylib 0x000000010a24d103 _T010Foundation27_KeyValueCodingAndObservingPAAE7observeAA05NSKeyC11ObservationCs0B4PathCyxqd__G_So0hcF7OptionsV7optionsyx_AA0hC14ObservedChangeVyqd__Gtc13changeHandlertlF + 4241106147
7  swift                    0x0000000104dbf74f llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) + 655
8  swift                    0x0000000104dc59b3 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, 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&, char const* const*) + 707
9  swift                    0x00000001041d2374 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 22532
10 swift                    0x00000001041cb304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7332
11 swift                    0x0000000104181728 main + 12248
12 libdyld.dylib            0x00007fffd5327235 start + 1
13 libdyld.dylib            0x000000000000000c start + 718114264
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret ../test.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk -swift-version 4 -color-diagnostics -module-name test
[1]    53047 illegal hardware instruction  DEVELOPER_DIR=/Applications/Xcode-beta.app/Contents/Developer xcrun swift  4

While it makes sense that this does not work, the error does nothing to indicate what the problem is.

@jckarter
Copy link
Member

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants