Skip to content

Fix NaturalArray assignment recursion causing LazyLoop stack overflow (without changing LazyLoop behavior)#102

Merged
DanexCodr merged 4 commits into
mainfrom
copilot/fix-lazyloop-error
Apr 14, 2026
Merged

Fix NaturalArray assignment recursion causing LazyLoop stack overflow (without changing LazyLoop behavior)#102
DanexCodr merged 4 commits into
mainfrom
copilot/fix-lazyloop-error

Conversation

Copilot AI commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

LazyLoop.cod was failing due to a runtime recursion path in natural-array assignment, and the previous workaround altered demo behavior. This change restores the original LazyLoop content and fixes the underlying engine issue so the demo can run as authored.

  • Runtime fix: avoid formula-triggering reads during assignment bookkeeping

    • Added NaturalArray.peekMaterialized(long index) to read only already-materialized values (cache / computedCache) without invoking formula evaluation.
    • Updated AssignmentHandler natural-array index assignment to use peekMaterialized(...) for previous value tracking before set(...).
  • Restore demo semantics

    • Reverted src/main/cod/demo/src/main/test/lazyloop/LazyLoop.cod to its original output checks (arr[2], arr[3], arr[24000], arr[24001]), removing the earlier behavior change.
  • Documentation alignment

    • Updated README wording to reflect that the fix is in runtime recursion handling, not in removing LazyLoop output lines.
// before
Object previous = natural.get(index);
natural.set(index, newValue);

// after
Object previous = natural.peekMaterialized(index);
natural.set(index, newValue);

@DanexCodr DanexCodr marked this pull request as ready for review April 14, 2026 07:58
@DanexCodr DanexCodr merged commit 656592c into main Apr 14, 2026
@DanexCodr DanexCodr deleted the copilot/fix-lazyloop-error branch April 14, 2026 07:58
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