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-6397] #keyPath doesn't work with ? sugar in case patterns #48947

Closed
lilyball mannequin opened this issue Nov 15, 2017 · 0 comments
Closed

[SR-6397] #keyPath doesn't work with ? sugar in case patterns #48947

lilyball mannequin opened this issue Nov 15, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@lilyball
Copy link
Mannequin

lilyball mannequin commented Nov 15, 2017

Previous ID SR-6397
Radar None
Original Reporter @lilyball
Type Bug
Status Resolved
Resolution Duplicate
Environment

Apple Swift version 4.0.2 (swiftlang-900.0.69.2 clang-900.0.38)
Target: x86_64-apple-macosx10.9

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

md5: 8322f86ed067f48daed43991a0c77edf

duplicates:

  • SR-5605 Parser fails on optional #keyPath in case

Issue Description:

The ? sugar in case patterns doesn't parse properly when found after a #keyPath expression:

import Foundation

class Foo: NSObject {
    @objc var bar: String = ""

    func wat() {
        let value: String? = "bar"
        switch value {
        case #keyPath(bar)?:
            print("bar")
        default:
            print("other")
        }
    }
}

This produces the following errors:

unnamed.swift:9:27: error: expected ':' after 'case'
        case #keyPath(bar)?:
                          ^
unnamed.swift:9:27: error: expected expression
        case #keyPath(bar)?:
                          ^
unnamed.swift:9:14: error: expression pattern of type 'String' cannot match values of type 'String?'
        case #keyPath(bar)?:
             ^~~~~~~~~~~~~
                          ?
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 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
Projects
None yet
Development

No branches or pull requests

0 participants