swiftlang / swiftlang/swift-syntax

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

Open
#2,047 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Swift
Stars
3.7k
Forks
553
Avg merge
5d 13h
Merged PRs (30d)
16

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.