Skip to content

🐛 fix(mq-check): propagate piped input to function calls inside let bindings#1461

Merged
harehare merged 3 commits intomainfrom
fix/mq-check-let-binding-piped-input
Mar 17, 2026
Merged

🐛 fix(mq-check): propagate piped input to function calls inside let bindings#1461
harehare merged 3 commits intomainfrom
fix/mq-check-let-binding-piped-input

Conversation

@harehare
Copy link
Copy Markdown
Owner

No description provided.

…indings

When `items | let x = first()` was used, the piped value was not passed
to `first()` as its implicit first argument, causing false type errors.

Three-part fix:
- Add Pass 2.7 in constraint generation to forward root-level Variable
  piped inputs to their initializer Call/Ref before Pass 3 runs
- Extend `might_receive_piped_input` to defer errors for Calls inside
  Variables that are children of Block/Function/Macro
- Add `propagate_piped_input_to_variable_initializer` in pipe.rs to
  re-process Call initializers in Block-level Variables during Pass 4
…iteration

Eliminates a second O(R) scan over root_symbols and removes one
`get_piped_input` HashMap lookup per root-level Variable by propagating
piped input to Variable initializers within the existing Pass 2 loop.
Copilot AI review requested due to automatic review settings March 17, 2026 11:26
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

This PR fixes a bug in the mq-check type checker where piped input was not propagated to function calls inside let bindings. For example, [1, 2, 3] | let x = first() | x would incorrectly produce type errors because first() didn't see the piped array as its implicit argument.

Changes:

  • Added propagate_piped_input_to_variable_initializer to forward piped types from Variable nodes to their initializer Call/Ref expressions in pipe chains.
  • Extended might_receive_piped_input to recognize calls nested inside Variable nodes within pipe-capable constructs, preventing premature error reporting.
  • Added integration tests for let bindings with piped function calls (first, last, length, upcase).

Reviewed changes

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

File Description
crates/mq-check/src/constraint.rs Pass 2 now also propagates piped input into Variable initializers for root-level pipe chains.
crates/mq-check/src/constraint/pipe.rs Refactored pipe-chain processing to handle SymbolKind::Variable via a new propagate_piped_input_to_variable_initializer function.
crates/mq-check/src/constraint/helpers.rs Extended might_receive_piped_input to handle grandparent check for Variable parents.
crates/mq-check/tests/integration_test.rs Added parameterized tests for let bindings with piped function calls.

{
let init_children = get_children(&children_index, cats.root_symbols[i]);
if let Some(&init_id) = init_children.last() {
ctx.set_piped_input(init_id, prev_ty);
@harehare harehare merged commit dc82d8f into main Mar 17, 2026
4 checks passed
@harehare harehare deleted the fix/mq-check-let-binding-piped-input branch March 17, 2026 12:37
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