source-academy/js-slang

CSE Machine: sequences with let/const should not be reordered

Opened this issue · 3 comments

1;
let x = 1;

currently gives:
Screenshot 2024-10-15 at 1 37 53 PM

which may give the correct result but which is confusing.

Is this not the correct behaviour? Since the control is read bottom-to-top?

let x = 0;
1;
2;
3;

gives the wrong result: 1, instead of 3.

I can't replicate this?

image

Sorry, messages crossed. Yes, I was confused. Only the first issue that I posted is valid. So the current post states the problem: a confusing reordering of statements, in case of const/let mixed with value-producing statements.