source-academy / js-slang

Implementations of sublanguages of JavaScript, TypeScript, Scheme and Python
https://source-academy.github.io/source/
Apache License 2.0
70 stars 104 forks source link

CSE Machine: Redeclaring name bug #1520

Closed DiligentPenguinn closed 9 months ago

DiligentPenguinn commented 9 months ago

While working on #1503 , I encountered a very weird bug https://share.sourceacademy.nus.edu.sg/m9578 The result of the program should be undefined but instead it throws an error: "Redeclaring name b"

Image

NhatMinh0208 commented 9 months ago

This seems to be the culprit. The env instruction only gets pushed when there is a statement node in the control stack, which is not the case here.

Removing said check (control.some(isNode)) solves the issue.

@martin-henz is it safe to just remove the check? Why is it in here anyway? Am I missing something?

NhatMinh0208 commented 9 months ago

Also this issue is probably related to #1506