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

Introduces numeric addition and subtraction across the MIR and interpreter with mixed-type support and optimizations.

  • Adds BinOp::Add/Sub and symbols; interpreter implements +/- for IntInt, NumNum, and mixed IntNum (overflow-aware via Numeric)
  • Enables constant folding and simplifications in inst_simplify for +/- (identity, cancellation), skipping on overflow; adds UI snapshots
  • Moves Int from body/constant to interpret/value and re-exports; updates imports and usages throughout
  • Updates builder/docs: Num type in body!, const_int now i128, operand builder accepts i128
  • Expands interpreter/unit tests for integer, float, mixed arithmetic and type-mismatch cases

Written by Cursor Bugbot for commit ee71a72. 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

indietyp commented Jan 10, 2026

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

@augmentcode
Copy link

augmentcode bot commented Jan 10, 2026

🤖 Augment PR Summary

Summary: Adds + / - as first-class binary operations in HashQL MIR and wires them through execution and optimization.

Changes:

  • Introduce `BinOp::Add` and `BinOp::Sub` and add operator string/symbol mappings.
  • Interpreter: evaluate `+`/`-` for `Int`, `Num`, and mixed `Int`↔`Num` operands with type-mismatch diagnostics.
  • Refactor integer handling: move `Int` into `interpret::value` and update constant/builder APIs to use `i128`.
  • Implement `Add`/`Sub` for `Int` and `Num` (including integer overflow behavior) and update imports across MIR/reify/visitor code.
  • Inst-simplify pass: add constant folding and algebraic identities for `+`/`-`; add unit + UI snapshot coverage.
  • Docs: extend MIR builder guide with the `Num` primitive type.

Technical Notes: Constant folding uses checked_add/checked_sub to avoid folding overflow cases; overflow behavior is handled at runtime.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. 2 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@indietyp indietyp force-pushed the bm/be-257-hashql-implement-interpreter branch from abb2e49 to e304b49 Compare January 17, 2026 17:55
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from 2e2c7ef to a6d5b81 Compare January 17, 2026 17:55
@graphite-app graphite-app bot changed the base branch from bm/be-257-hashql-implement-interpreter to graphite-base/8250 January 19, 2026 11:05
@indietyp indietyp force-pushed the bm/be-272-hashql-implement-and-inside-the-mir branch from a6d5b81 to ee71a72 Compare January 19, 2026 14:49
@graphite-app graphite-app bot changed the base branch from graphite-base/8250 to main January 19, 2026 14:49
@graphite-app
Copy link
Contributor

graphite-app bot commented Jan 19, 2026

Merge activity

  • Jan 19, 2:49 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

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