Skip to content

Add a high-level API to extract an argument from a LabeledExprListSyntax #2047

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

Open
ahoppen opened this issue Aug 9, 2023 · 2 comments
Open
Assignees
Labels
enhancement New feature or request

Comments

@ahoppen
Copy link
Member

ahoppen commented Aug 9, 2023

A very common task for macros is to extract the argument for a specific function parameter. Instead of having each macro dig through the LabeledExprListSyntax, we should offer a high-level API that does this.

Designing such an API will probably be non-trivial. Ideally, you pass it the signature of the function/macro parameters and it performs the parameter matching logic in the same way that the type checker does. This means, that the API will need to figure out how to match arguments to variadic parameters, how to handle defaulted parameters and how to handle parameter packs.

After we have implemented the parameter matching logic, we would need a way to query the match result. I think two queries that should at least be supported is to get the argument for a specific argument label and to get the arguments at a specific parameter index.

@ahoppen ahoppen added the enhancement New feature or request label Aug 9, 2023
@ahoppen
Copy link
Member Author

ahoppen commented Aug 9, 2023

Tracked in Apple’s issue tracker as rdar://113653955

@AppAppWorks
Copy link
Contributor

Could I be assigned with this task? It's going to take me quite a long time to finish though ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants