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-13999] Key path literal is not promoted to optional function argument #56393

Closed
stephencelis opened this issue Dec 27, 2020 · 1 comment · Fixed by #70337
Closed

[SR-13999] Key path literal is not promoted to optional function argument #56393

stephencelis opened this issue Dec 27, 2020 · 1 comment · Fixed by #70337
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself expressions Feature: expressions key paths Feature: key paths (both native and Objective-C) literals Feature → expressions: Literals such as an integer or string literal swift 6.0 type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error

Comments

@stephencelis
Copy link
Contributor

stephencelis commented Dec 27, 2020

Previous ID SR-13999
Radar rdar://problem/72864716
Original Reporter @stephencelis
Type Bug
Environment

Swift 5.3

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

md5: a9f7396121fd5e36171f6af4efec596f

Issue Description:

Copy the following into a playground:

extension Collection {
  func prefix<R: RangeExpression>(
    _ range: R,
    while predicate: ((Element) -> Bool)? = nil
  ) -> SubSequence where R.Bound == Self.Index {
    let xs = self[range]
    return predicate.map { xs.prefix(while: $0) } ?? xs
  }
}

Array("42 test")
  .prefix(1...4, while: { $0.isNumber })

Array("42 test")
  .prefix(1...4, while: \.isNumber)

I'd expect the final lines to compile, but they do not.

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
xedin added a commit to xedin/swift that referenced this issue Dec 8, 2023
… key path type

The key path is going to be implicitly wrapped into a contextual
optional type.

Resolves: rdar://72864716
Resolves: apple#56393
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself unexpected error Bug: Unexpected error swift 6.0 type checker Area → compiler: Semantic analysis key paths Feature: key paths (both native and Objective-C) type inference Feature: type inference literals Feature → expressions: Literals such as an integer or string literal expressions Feature: expressions and removed type inference Feature: type inference labels Dec 12, 2023
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this issue Jan 19, 2024
… key path type

The key path is going to be implicitly wrapped into a contextual
optional type.

Resolves: rdar://72864716
Resolves: apple#56393
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 expressions Feature: expressions key paths Feature: key paths (both native and Objective-C) literals Feature → expressions: Literals such as an integer or string literal swift 6.0 type checker Area → compiler: Semantic analysis unexpected error Bug: Unexpected error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants