source-academy/js-slang

CSE Machine: Array expressions evaluated in wrong order.

Closed this issue · 1 comments

For input [1,2,3];
image

Should be the opposite order:
arr 3, 3,2,1.

The CSE machine in the lecture is correct.

@martin-henz Are we sure we want to handle array literals this way? The current approach shown above makes more sense: We push values into the control in the order encountered in the parse tree, and then when the array literal instruction is called the values in the
stack are in reverse order, so the machine can just pop the values and put them into the array in order.

Edit: Nevermind, I was wrong.