source-academy/js-slang

CSE Machine: Visualization shows unreferenced globals

Closed this issue · 2 comments

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.

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.

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.