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: Visualization shows unreferenced globals #1595

Closed NhatMinh0208 closed 8 months ago

NhatMinh0208 commented 8 months ago

When running a program, the CSE machine visualization shows unreferenced globals instead of only referenced ones:

Investigation

It appears the bug was caused by #1584; more specifically, these changes to interpreter.js which causes some globals to be referenced by the program environment.

NhatMinh0208 commented 8 months ago

Update

Apparently program environments have been created with currentEnvironment as tail instead of the global environment.

This causes the check in the code above to not work properly.

NhatMinh0208 commented 8 months ago

On further inspection, it appears that prelude environments are given the name 'programEnvironment' instead of a unique name that indicates the prelude. As a result, the check in the code above picks up the first program environment erroneously.