-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
Description
At the end of Chapter 24.3, clox is once again running. However, I think Chapter 24 introduced a bug in how REPL is being handled.
If I run
{var a = 123; print a;}
it works as expected and prints 123.
But if I run it again in the same REPL session it does not print anything.
The issue is that we push another copy of the implicit function onto the vm stack, thus throwing off what the compiler set as the slot for the variable.
My fix was to add:
resetStack();
in the interpret() function in vm.c just before we push the SCRIPT wrapper function.
Is that the correct way to fix this bug? Perhaps later in the book the bug gets fixed in some other manner; I have not gotten that far yet.
Metadata
Metadata
Assignees
Labels
No labels