Skip to content

✨ feat(mq-lang): add value as name variable binding syntax#1781

Merged
harehare merged 1 commit into
mainfrom
feat/as-binding
May 23, 2026
Merged

✨ feat(mq-lang): add value as name variable binding syntax#1781
harehare merged 1 commit into
mainfrom
feat/as-binding

Conversation

@harehare

Copy link
Copy Markdown
Owner

Implements jq-style expr as name binding across all language layers

Implements jq-style `expr as name` binding across all language layers

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds jq-style expr as name bindings to the mq language, threading the new syntax through lexing, CST/AST parsing, evaluation, HIR lowering, and formatting so bindings can be introduced mid-pipeline and referenced later.

Changes:

  • Introduces as as a keyword/token and parses it into new CST/AST nodes (NodeKind::As / Expr::As).
  • Implements evaluation semantics for as bindings by defining the name in the current environment while passing through the prior pipeline value.
  • Extends HIR lowering and the formatter to understand/print as bindings, and adds integration/formatter/parser tests.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/mq-lang/tests/property_based_tests.rs Excludes as from generated identifiers to avoid keyword collisions.
crates/mq-lang/tests/integration_tests.rs Adds eval-level integration coverage for expr as name usage in pipelines and defs.
crates/mq-lang/src/macro_expand.rs Supports macro expansion/substitution for the new Expr::As node.
crates/mq-lang/src/lexer/token.rs Adds TokenKind::As and display formatting.
crates/mq-lang/src/lexer.rs Recognizes as as a keyword during lexing.
crates/mq-lang/src/eval.rs Evaluates Expr::As by binding the evaluated value into the environment and returning the incoming pipeline value.
crates/mq-lang/src/cst/parser.rs Parses as bindings into CST (NodeKind::As).
crates/mq-lang/src/cst/node.rs Adds As to CST node kinds.
crates/mq-lang/src/ast/parser.rs Parses as bindings into AST (Expr::As) and adds a unit test.
crates/mq-lang/src/ast/node.rs Adds Expr::As and ensures range calculation covers the inner node consistently with similar constructs.
crates/mq-lang/src/ast/code.rs Adds code formatting output for Expr::As.
crates/mq-hir/src/hir/lower.rs Lowers CST As into HIR symbols (keyword + variable + initializer relationship).
crates/mq-formatter/src/formatter.rs Formats as bindings and adds formatter tests.

Comment thread crates/mq-lang/tests/integration_tests.rs
@codspeed-hq

codspeed-hq Bot commented May 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/as-binding (fcf33ba) with main (5d610fe)

Open in CodSpeed

@harehare harehare merged commit 1d5fde9 into main May 23, 2026
14 checks passed
@harehare harehare deleted the feat/as-binding branch May 23, 2026 09:24
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