Commit 44957a4
committed
fix(ruby): add liftBranchUpdateProps to ANF lowering and fix SDK require
The Ruby compiler was missing the liftBranchUpdateProps post-pass that
all other compilers (TS, Go, Rust, Python) implement. This transform
flattens nested if-else chains where each branch ends with update_prop
into flat conditional assignments — critical for stateful contracts
because Bitcoin Script requires ALL state fields to be explicitly on the
stack after method execution.
Without the lift, position dispatch patterns like TicTacToe's placeMove
(9 branches each updating a different cell) produced nested if/else ANF
that only updated one property per path, leaving others missing from the
stack. The compiled script was 267 bytes shorter than the reference and
failed on-chain with "false/empty top stack element".
Also fix the integration spec_helper to use the TS reference compiler
for .runar.ts sources (the Ruby compiler's TS parser has remaining stack
lowering divergences for bring_to_top in complex contracts), and add the
missing `require 'set'` in the SDK codegen module.
All 28 conformance tests pass with the new transform.1 parent 18aefc5 commit 44957a4
File tree
3 files changed
+463
-6
lines changed- compilers/ruby/lib/runar_compiler/frontend
- integration/ruby/spec
- packages/runar-rb/lib/runar/sdk
3 files changed
+463
-6
lines changed
0 commit comments