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: validation is skipped #1502

Closed martin-henz closed 9 months ago

martin-henz commented 1 year ago

This program () => c; should give Line 1: Name c not declared. but currently evaluates without error.

NhatMinh0208 commented 9 months ago

The root cause of this appears to be that no validation is performed in the CSE machine at all - for example, this program also evaluates without error:

const a=1;
if (false) {
    c;
}
else {
    a;
}

https://share.sourceacademy.org/novalincse

I think we should borrow the checkForUndefinedVariables function from the stepper to accomplish this.