Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clox functionality is not entirely unchanged after section 24.3 #1099

Open
danielbendix opened this issue Dec 28, 2022 · 0 comments
Open

clox functionality is not entirely unchanged after section 24.3 #1099

danielbendix opened this issue Dec 28, 2022 · 0 comments

Comments

@danielbendix
Copy link

In the last paragraph of section 24.3, the book reads: "Assuming we did all of that correctly, we got clox back to a runnable state. Fire it up and it does... exactly what it did before.".

This is not entirely true. In interpret, the initial function is pushed to the stack, and at this point it's only popped if a runtime error occurs. This means that successive invocations of the REPL without errors will have issues with locals, as the bytecode only expects there to be one value in the frame when the bytecode starts being executed.

The issue is fixed in 24.5.4 with the new code for OP_RETURN, which pops the value from the stack.

It might be worth changing the wording, since this can cause some confusion for readers that are following along, and want to test their code after section 24.3.

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

No branches or pull requests

1 participant