✨ feat: support variadic function arguments and enhance error handling#1214
Merged
✨ feat: support variadic function arguments and enhance error handling#1214
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces support for variadic function arguments (e.g., *args) to the mq language, allowing functions to accept a variable number of arguments. The implementation includes comprehensive validation to prevent invalid variadic parameter usage, such as ensuring variadic parameters are always last and prohibiting their use in macros.
Changes:
- Added variadic parameter support to the AST, parser, evaluator, and HIR
- Implemented validation rules: variadic parameters must be last, only one allowed per function, and macros cannot have variadic parameters
- Updated LSP, formatter, and HIR to properly display and handle variadic parameters
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/mq-lsp/src/hover.rs | Updated hover display to use to_string() for parameters to include variadic notation |
| crates/mq-lsp/src/completions.rs | Updated completion snippet generation to support variadic parameter display |
| crates/mq-lang/tests/integration_tests.rs | Added comprehensive test cases for variadic parameter functionality and error conditions |
| crates/mq-lang/src/eval.rs | Implemented variadic argument collection and modified argument count validation logic |
| crates/mq-lang/src/error/syntax.rs | Added new error types for variadic parameter validation |
| crates/mq-lang/src/error.rs | Added diagnostic messages for variadic parameter errors |
| crates/mq-lang/src/cst/parser.rs | Extended CST parser to recognize and parse variadic parameter syntax |
| crates/mq-lang/src/ast/parser.rs | Implemented AST-level variadic parameter parsing and validation |
| crates/mq-lang/src/ast/node.rs | Added is_variadic field to Param struct and updated display formatting |
| crates/mq-hir/src/symbol.rs | Added is_variadic field to ParamInfo and updated symbol display |
| crates/mq-hir/src/hir.rs | Updated HIR to detect and track variadic parameters from CST |
| crates/mq-formatter/src/formatter.rs | Enhanced formatter to correctly output variadic parameter syntax |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.