Skip to content

BE-481: HashQL: Reify null and empty tuple as unit constants#8853

Open
indietyp wants to merge 1 commit into
bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-apifrom
bm/be-481-hashql-lower-null-to-constantunit-during-reification
Open

BE-481: HashQL: Reify null and empty tuple as unit constants#8853
indietyp wants to merge 1 commit into
bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-apifrom
bm/be-481-hashql-lower-null-to-constantunit-during-reification

Conversation

@indietyp

Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

During MIR reification, null primitive values and empty tuples were not being lowered to the canonical unit constant (). This meant that null literals and #tuple: [] expressions were handled inconsistently compared to other unit-like values. This PR ensures both are promoted to Constant::Unit during reification, aligning them with the existing treatment of unit expressions.

🔍 What does this change?

  • Primitive::Null is now matched before the general Primitive arm in both atom.rs and rvalue.rs, lowering it directly to Constant::Unit instead of falling through to the opaque constant path.
  • Empty tuples (Tuple { fields } where fields.is_empty()) are now lowered to Constant::Unit in rvalue.rs rather than being constructed as a zero-field aggregate.
  • Existing snapshot tests for filter-aggressive have been updated to reflect that null comparisons now display as == () rather than == null in MIR output.

🛡 What tests cover this?

  • New UI test reify/null-value verifies that a null literal is reified as a unit constant.
  • New UI test reify/null-value-in-binary verifies that null values used in binary expressions (e.g. equality comparisons) are correctly promoted to ().
  • New UI test reify/empty-tuple verifies that an empty tuple expression is reified as a unit constant.

❓ How to test this?

  1. Run the MIR UI tests: cargo test -p hashql-mir
  2. Confirm all new and existing snapshot tests pass.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

Copilot AI review requested due to automatic review settings June 11, 2026 12:34
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jun 23, 2026 10:00am
petrinaut Ready Ready Preview Jun 23, 2026 10:00am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jun 23, 2026 10:00am

@cursor

cursor Bot commented Jun 11, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Scoped to internal MIR lowering and test output; behavior change is intentional normalization of null/empty-tuple to unit, with no auth or external API surface touched.

Overview
MIR reification now treats null literals and empty #tuple values as the canonical unit constant () instead of opaque primitives or zero-field tuple aggregates.

In reify/atom.rs and reify/rvalue.rs, Primitive::Null is handled in a dedicated arm that lowers to Constant::Unit (operand/load paths). Empty tuples short-circuit to the same unit constant rather than building a tuple aggregate. MIR snapshots reflect this—e.g. comparisons against null show as == () in filter-aggressive. New UI reify tests cover standalone null, null in binary ==, and empty tuples.

Reviewed by Cursor Bugbot for commit 41cf466. Bugbot is set up for automated code reviews on this repo. Configure here.

indietyp commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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

This PR standardizes MIR reification so that null literals and empty tuple literals are lowered to the canonical unit constant Constant::Unit (()), aligning them with existing unit-expression handling and making MIR output consistent.

Changes:

  • Reify Primitive::Null directly into Constant::Unit in both atom and rvalue lowering.
  • Reify empty tuple literals (#tuple: []) into Constant::Unit instead of a zero-field tuple aggregate.
  • Add new MIR UI tests for null and empty tuple reification, and update an existing snapshot to reflect == () comparisons.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libs/@local/hashql/mir/src/reify/rvalue.rs Lowers null primitives and empty tuple data nodes to Constant::Unit during rvalue reification.
libs/@local/hashql/mir/src/reify/atom.rs Lowers null primitives to Constant::Unit when reifying atom operands.
libs/@local/hashql/mir/tests/ui/reify/null-value.jsonc Adds UI test input asserting null literal is promoted to unit.
libs/@local/hashql/mir/tests/ui/reify/null-value.stdout Adds expected MIR output showing return () for null.
libs/@local/hashql/mir/tests/ui/reify/null-value-in-binary.jsonc Adds UI test input asserting null promotion inside a binary expression.
libs/@local/hashql/mir/tests/ui/reify/null-value-in-binary.stdout Adds expected MIR output showing null operands lowered to () before comparison.
libs/@local/hashql/mir/tests/ui/reify/empty-tuple.jsonc Adds UI test input asserting empty tuple literal is promoted to unit.
libs/@local/hashql/mir/tests/ui/reify/empty-tuple.stdout Adds expected MIR output showing empty tuple lowered to ().
libs/@local/hashql/mir/tests/ui/pass/inline/filter-aggressive.stdout Updates snapshot output to reflect null comparisons now printing as == ().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codspeed-hq

codspeed-hq Bot commented Jun 11, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 24 untouched benchmarks
⏩ 56 skipped benchmarks1


Comparing bm/be-481-hashql-lower-null-to-constantunit-during-reification (41cf466) with bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api (211e26c)

Open in CodSpeed

Footnotes

  1. 56 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.77%. Comparing base (211e26c) to head (41cf466).

Additional details and impacted files
@@                                      Coverage Diff                                       @@
##           bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api    #8853   +/-   ##
==============================================================================================
  Coverage                                                          56.77%   56.77%           
==============================================================================================
  Files                                                                390      390           
  Lines                                                              63060    63060           
  Branches                                                            1060     1060           
==============================================================================================
  Hits                                                               35802    35802           
  Misses                                                             26882    26882           
  Partials                                                             376      376           
Flag Coverage Δ
rust.hashql-compiletest 28.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@indietyp indietyp force-pushed the bm/be-481-hashql-lower-null-to-constantunit-during-reification branch from 9bd6d9b to 912034f Compare June 12, 2026 11:08
@indietyp indietyp force-pushed the bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api branch from 585c91d to 1622d96 Compare June 12, 2026 11:08
@vercel vercel Bot temporarily deployed to Preview – petrinaut June 12, 2026 11:08 Inactive
@indietyp indietyp force-pushed the bm/be-481-hashql-lower-null-to-constantunit-during-reification branch from 912034f to 95715c4 Compare June 12, 2026 12:33
Copilot AI review requested due to automatic review settings June 12, 2026 12:33
@indietyp indietyp force-pushed the bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api branch from 1622d96 to c541263 Compare June 12, 2026 12:33
@indietyp indietyp force-pushed the bm/be-481-hashql-lower-null-to-constantunit-during-reification branch from f1a6855 to 942f634 Compare June 19, 2026 15:14
@indietyp indietyp force-pushed the bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api branch from 8a9093a to 1c0b8e6 Compare June 19, 2026 15:14
@indietyp indietyp force-pushed the bm/be-537-hashql-remove-old-backend-wire-up-hashql-in-the-api branch from 1c0b8e6 to 4453868 Compare June 22, 2026 10:51
Copilot AI review requested due to automatic review settings June 22, 2026 10:51
@indietyp indietyp force-pushed the bm/be-481-hashql-lower-null-to-constantunit-during-reification branch from 942f634 to 3ab5811 Compare June 22, 2026 10:51

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

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

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants