Skip to content

Improve compiler stack binding codegen and state-template support#84

Merged
someone235 merged 48 commits intokaspanet:masterfrom
michaelsutton:compiler-misc
Mar 26, 2026
Merged

Improve compiler stack binding codegen and state-template support#84
someone235 merged 48 commits intokaspanet:masterfrom
michaelsutton:compiler-misc

Conversation

@michaelsutton
Copy link
Copy Markdown
Contributor

This PR extracts the compiler-side work from the chess line without the examples/ changes.

It includes:

  • stack-binding refactors and new stack reordering helpers
  • O(1) stack-local rebinding with branch-safe reconciliation
  • dedicated stack_bindings module and unit tests
  • IndexSet-backed stack binding tracking with stricter dense-depth invariants
  • struct-leaf stack rebinding fixes and related compiler/debugger test coverage
  • validateOutputStateWithTemplate compiler support and follow-up fixes
  • cross-template input-state reading / typed state-template handling
  • OpTxInputDaaScore exposure in the compiler/builtins surface
  • related compiler tests, debugger-session tests, builtin signatures, and syntax-highlighting/docs updates

(cherry picked from commit 385a12c)
Inline calls now allow mutable scalar stack locals unconditionally.

The previous flag was redundant once both normal and inline compilation used the stack-local rebinding path, so this change removes enable_mutable_scalar_stack_locals from the compiler plumbing.

The real fix is keeping env synchronized when a stack-bound scalar is reassigned:
- after emit_update_stack_for_rebinding(...)
- rewrite self-references in the new RHS against the previous semantic value
- resolve the updated expression back into env

That fixes inline returns reading stale values while avoiding the self-referential cycles from the naive env.insert(name, lowered_expr) approach.
@someone235 someone235 merged commit c06f4cc into kaspanet:master Mar 26, 2026
4 checks passed
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