sjbarag / brs

An interpreter for the BrightScript language that runs on non-Roku platforms.
MIT License
114 stars 43 forks source link

fix(interp): Don't modify defaultExecutionOptions after creation #597

Closed sjbarag closed 3 years ago

sjbarag commented 3 years ago

Using Object.assign() without an initial {} overwrote values in defaultExecutionOptions in a "last overwrite wins" pattern. This caused the produced interpreter to execute functions like ListFiles() relative to the temporary directory the final component library is unzipped into, rather than relative to the process's current working directory.

Use the object spread syntax instead of Object.assign() since it's harder to get wrong, and freeze the defaultExecutionOptions variable after creation to prevent accidental modification.