Skip to content

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

Description

@ahoppen

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions