fix(vm): a text run from inside a line no longer takes the line's place -- LOAD and THRU go on with the rest of it
FABRIC-3.md XXXIV.1, traced and fixed. vm_interpret() copied each text into the VM's one input buffer and reset the position. LOAD runs its block by calling it, so the block replaced the line LOAD was on and nothing after LOAD or THRU on that line was ever interpreted; the same for -->, a capsule's EXEC and a message kernel-Hermes delivers. vm_interpret() now keeps what the outer text had not yet read when it is called from inside another, and puts it back after, as FORTH-79's LOAD keeps the input stream it interrupts. In the kernel's VM and the hosted one alike. POST: LOAD.rest_of_line (1 LOAD 0 0 /) and THRU.rest_of_line (1 2 THRU 0 0 /) failed without the fix (logs/20261014-061222) and pass with it. Three-ISA acceptance: logs/20261014-061508 (amd64), -061624 (aarch64), -061837 (riscv64), 1052 tests, none failed, zuse prompt, hash 0x08873e0f44b7cb2a unchanged. The hosted binary: 100 LOAD 1 + . gives 8. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9772ee8b68
commit
c15589b39e
@@ -129,9 +129,12 @@ static WordTestSuite block_word_suites[] = {
|
||||
{"zero_block", "0 LOAD", "Should handle block 0", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
{"nonexistent", "9999 LOAD", "Should handle missing block", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
{"empty_stack", "LOAD", "Should cause stack underflow", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
/* The line goes on after the block (FABRIC-3.md XXXIV.1): the division after LOAD runs, and fails.
|
||||
* Before 2026-10-14 the block took the line's place and nothing after LOAD was ever interpreted. */
|
||||
{"rest_of_line", "1 LOAD 0 0 /", "The rest of the line is interpreted after LOAD", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||||
},
|
||||
4, {0}
|
||||
5, {0}
|
||||
},
|
||||
|
||||
{
|
||||
@@ -173,6 +176,8 @@ static WordTestSuite block_word_suites[] = {
|
||||
|
||||
/* Stack underflow */
|
||||
{"empty_stack", "THRU", "Should cause stack underflow (no args)", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
/* the line goes on after the blocks (FABRIC-3.md XXXIV.1) */
|
||||
{"rest_of_line", "1 2 THRU 0 0 /", "The rest of the line is interpreted after THRU", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
{"one_arg", "1 THRU", "Should cause stack underflow (one arg)", TEST_ERROR_CASE, 1, 1, {0}},
|
||||
|
||||
/* Range tests */
|
||||
@@ -186,7 +191,7 @@ static WordTestSuite block_word_suites[] = {
|
||||
|
||||
{NULL, NULL, NULL, TEST_NORMAL, 0, 0, {0}}
|
||||
},
|
||||
17, {0}
|
||||
18, {0}
|
||||
},
|
||||
|
||||
/* End marker */
|
||||
|
||||
Reference in New Issue
Block a user