Skip to content

Conversation

@indietyp
Copy link
Member

🌟 What is the purpose of this PR?

Add support for addition and subtraction operations in HashQL MIR

🔍 What does this change?

  • Adds Add and Sub binary operations to the MIR
  • Implements addition and subtraction for integers and floating-point numbers
  • Supports mixed-type operations (int + float, float + int)
  • Adds constant folding and optimization for addition and subtraction
  • Updates the MIR builder guide to include the Num type
  • Moves Int type from constant module to interpret/value module for better organization

🛡 What tests cover this?

  • Added unit tests for integer addition and subtraction
  • Added tests for floating-point addition and subtraction
  • Added tests for mixed-type operations
  • Added tests for constant folding and optimization
  • Added tests for edge cases like overflow handling

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:

  • require changes to docs which are made as part of this PR

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

The changes in this PR:

  • do not affect the execution graph

@cursor
Copy link

cursor bot commented Jan 10, 2026

PR Summary

Adds arithmetic to MIR and aligns types/builders for broader numeric support.

  • Introduces BinOp::Add/Sub; implements evaluation for Int, Num, and mixed operands in the interpreter via new Int/Num Add/Sub impls
  • Moves Int from body::constant to interpret::value; updates imports across interpreter, visitors, reifier
  • Builder changes: const_int now takes i128; OperandBuilder builds i128; body! macro/type mapping gains Num
  • Instruction simplify pass: adds constant folding for +/- (checked to avoid overflow) and algebraic identities (e.g., x+0=>x, x-0=>x, 0-x=>-x, x-x=>0)
  • Docs: builder guide updated (adds Num, lists +/-)
  • Tests: new runtime and pass tests for ints/floats/mixed ops, overflow non-folding, and type-mismatch diagnostics; snapshot updates included

Written by Cursor Bugbot for commit a6d5b81. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels Jan 10, 2026
Copy link
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.

@graphite-app graphite-app bot requested review from a team January 10, 2026 18:26
@vercel vercel bot temporarily deployed to Preview – petrinaut January 10, 2026 18:30 Inactive
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from 6612cd1 to d999354 Compare January 15, 2026 13:31
@indietyp indietyp force-pushed the bm/be-257-hashql-implement-interpreter branch from 3fcddd3 to 96a6837 Compare January 15, 2026 13:31
@vercel
Copy link

vercel bot commented Jan 15, 2026

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

2 Skipped Deployments
Project Deployment Review Updated (UTC)
ds-theme Ignored Ignored Preview Jan 17, 2026 5:56pm
hashdotdesign Ignored Ignored Preview Jan 17, 2026 5:56pm

@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from d999354 to ca727c1 Compare January 15, 2026 15:22
@indietyp indietyp force-pushed the bm/be-257-hashql-implement-interpreter branch from 051b87a to 4a4305b Compare January 16, 2026 10:38
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from ca727c1 to 37f0a1a Compare January 16, 2026 10:38
@indietyp indietyp force-pushed the bm/be-257-hashql-implement-interpreter branch from 4a4305b to 28ae173 Compare January 16, 2026 13:46
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from 37f0a1a to b84adb7 Compare January 16, 2026 13:46
@indietyp indietyp force-pushed the bm/be-257-hashql-implement-interpreter branch from 28ae173 to abb2e49 Compare January 17, 2026 16:17
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from b84adb7 to 2e2c7ef Compare January 17, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/infra Relates to version control, CI, CD or IaC (area) 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.

3 participants