Skip to content

✨ feat(parser): support index assignment for arrays and dicts#1235

Merged
harehare merged 2 commits intomainfrom
feat/index-assignment
Feb 8, 2026
Merged

✨ feat(parser): support index assignment for arrays and dicts#1235
harehare merged 2 commits intomainfrom
feat/index-assignment

Conversation

@harehare
Copy link
Copy Markdown
Owner

@harehare harehare commented Feb 8, 2026

Desugar arr[idx] = rhs into arr = set(arr, idx, rhs) and support compound assignment operators (+=, -=, etc.) on indexed targets.

Desugar `arr[idx] = rhs` into `arr = set(arr, idx, rhs)` and support
compound assignment operators (`+=`, `-=`, etc.) on indexed targets.
Copilot AI review requested due to automatic review settings February 8, 2026 13:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds parsing + desugaring support for indexed assignment targets so expressions like arr[idx] = rhs are lowered into arr = set(arr, idx, rhs), including compound assignment operators on indexed targets.

Changes:

  • Extend AST assignment construction to recognize indexed LHS (represented as get(base, idx)) and desugar into set(...).
  • Add SET AST constant for the new desugaring target.
  • Add CST/AST/HIR/formatter tests covering indexed assignment and some compound forms.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
crates/mq-lang/src/cst/parser.rs Adds CST-level test cases for index assignment and index compound assignment tokens/shape.
crates/mq-lang/src/ast/parser.rs Implements indexed-target handling in assignment creation + adds AST tests for =, +=, and //= on indexed targets.
crates/mq-lang/src/ast/constants.rs Introduces SET constant used by the new desugaring.
crates/mq-hir/src/hir.rs Adds HIR smoke tests ensuring indexed assignment parses/lower without errors and produces expected symbols.
crates/mq-formatter/src/formatter.rs Adds formatter test cases for indexed assignment and += on indexed targets.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Feb 8, 2026

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/index-assignment (9be27fc) with main (df71121)

Open in CodSpeed

@harehare harehare requested a review from Copilot February 8, 2026 13:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

@harehare harehare merged commit 7c6e391 into main Feb 8, 2026
7 checks passed
@harehare harehare deleted the feat/index-assignment branch February 8, 2026 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants