You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Context: Scope of the entire program is statically set only once. This can potentially create a problem while re-running the code without refreshing the browser. The static scope will persist if the user doesn't refresh the browser tab.
I have observed this while testing:
While running multiple cases one after other, the variables in scope of previous test case were interfering with the current test case variables. To resolve this in testing, I did a scope reset before each test case.
Possible scenario demonstration:
Code 1:
hi bhai;
bhai ye hai a = 7;
bye bhai;
Code 2:
hi bhai;
bhai ye hai a = 30, b = 4;
bye bhai;
Let's say this code 1 runs in the browser and then user runs code 2 in the browser without refreshing the tab, the variable "a" from code 1 will persist in the scope and while running code 2, an error will be thrown.
Possible solution:
in interpret method:
interpret(code: string) {
const ast = this._parser.parse(code);
InterpreterModule.getVisitor(ast.type).visitNode(ast);
InterpreterModule.setCurrentScope(new Scope(null)); // this will make sure that scope is reset after running the code.
}
The text was updated successfully, but these errors were encountered:
Context: Scope of the entire program is statically set only once. This can potentially create a problem while re-running the code without refreshing the browser. The static scope will persist if the user doesn't refresh the browser tab.
I have observed this while testing:
While running multiple cases one after other, the variables in scope of previous test case were interfering with the current test case variables. To resolve this in testing, I did a scope reset before each test case.
Possible scenario demonstration:
Code 1:
Code 2:
Let's say this code 1 runs in the browser and then user runs code 2 in the browser without refreshing the tab, the variable "a" from code 1 will persist in the scope and while running code 2, an error will be thrown.
Possible solution:
in interpret method:
The text was updated successfully, but these errors were encountered: