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-5865] Key path expression is "ambiguous without more context" #48435

Closed
ole opened this issue Sep 10, 2017 · 4 comments
Closed

[SR-5865] Key path expression is "ambiguous without more context" #48435

ole opened this issue Sep 10, 2017 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@ole
Copy link
Contributor

ole commented Sep 10, 2017

Previous ID SR-5865
Radar rdar://problem/34376681
Original Reporter @ole
Type Bug
Status Closed
Resolution Duplicate
Environment

Xcode 9 beta 6 (9M214v)

macOS 10.13 Beta 9 (17A360a)

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

md5: af136a99619be2c3353e5e9d117d7e3d

duplicates:

  • SR-7380 KeyPath cannot infer type in [keyPath:] context

is duplicated by:

  • SR-5973 Abbreviated key path subscript notation is ambiguous

Issue Description:

The expression "Hello"[keyPath: .count] returns an error on the key path argument: type of expression is ambiguous without more context. Both "Hello".count and "Hello"[keyPath: \String.count] work.

> swift
Welcome to Apple Swift version 4.0 (swiftlang-900.0.63.10 clang-900.0.36). Type :help for assistance.
  1> "Hello"[keyPath: \.count]
error: repl.swift:1:18: error: type of expression is ambiguous without more context
"Hello"[keyPath: \.count]
                 ^~~~~~~

  1> "Hello".count
$R0: String.IndexDistance = 5
  2> "Hello"[keyPath: \String.count]
$R1: String.IndexDistance = 5

SR-5295 is another key-path-related issue that produces the same error message, but it doesn't look like the two are related.

@ole
Copy link
Contributor Author

ole commented Sep 10, 2017

@jckarter
Copy link
Member

@swift-ci create

@ole
Copy link
Contributor Author

ole commented Apr 1, 2018

Update: this still doesn't compile with Swift 4.1 (tested on macOS 10.13.3 with Xcode 9.3 (9E145)).

@mdiep
Copy link
Contributor

mdiep commented Jun 11, 2018

This is a duplicate of SR-7380. (Closing in favor of that issue, even though it was reported later, because it has helpful commentary and an open PR.)

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants