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

Dynamic member lookup subscript should support file:line: default parameters #59706

Open
stephencelis opened this issue Jun 25, 2022 · 2 comments
Labels
attributes Feature: Declaration and type attributes compiler The Swift compiler itself default arguments Feature: default arguments for value parameters @dynamicMemberLookup Feature → attributes: the @dynamicMemberLookup attribute feature A feature request or implementation

Comments

@stephencelis
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Dynamic member lookup subscript should support file:line: default parameters. Knowing the calling context of the lookup can be important for surfacing where the source origin of a problem is.

Describe the solution you'd like

The following code should compile:

@dynamicMemberLookup
struct S<T> {
  var wrappedValue: T
  subscript<U>(
    dynamicMember keyPath: KeyPath<T, U>
    // Comment the next line out and all is well.
    , file: StaticString = #file, line: UInt = #line
  ) -> U {
    self.wrappedValue[keyPath: keyPath]
  }
}
@filip-sakel
Copy link
Contributor

If this wasn’t mentioned in the key-path dynamic member lookup proposal, I think it has to go through Swift evolution.

@stephencelis
Copy link
Contributor Author

@filip-sakel Posted https://forums.swift.org/t/add-default-parameter-support-e-g-file-to-dynamic-member-lookup/58490, but despite some hearts, not a ton of discussion.

@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself feature A feature request or implementation attributes Feature: Declaration and type attributes @dynamicMemberLookup Feature → attributes: the @dynamicMemberLookup attribute default arguments Feature: default arguments for value parameters and removed new feature labels Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attributes Feature: Declaration and type attributes compiler The Swift compiler itself default arguments Feature: default arguments for value parameters @dynamicMemberLookup Feature → attributes: the @dynamicMemberLookup attribute feature A feature request or implementation
Projects
None yet
Development

No branches or pull requests

3 participants