1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-29 06:55:07 +00:00
serenity/Libraries/LibJS
Yonatan Goldschmidt b184f12aaf LibJS: Limit scope of 'for' loop variables
This required 2 changes:
1. In the parser, create a new variable scope, so the variable is
   declared in it instead of the scope in which the 'for' is found.
2. On execute, push the variable into the newly created block. Existing
   code created an empty block (no variables, no arguments) which
   allows Interpreter::enter_scope() to skip the creation of a new
   environment, therefore when the variable initializer is executed, it
   sets the variable to the outer scope. By attaching the variable to
   the new block, the block gets a new environment.

This is only needed for 'let' / 'const' declarations, since 'var'
declarations are expected to leak.

Fixes: #2103
2020-05-07 23:31:49 +02:00
..
Heap LibJS: run clang-format on all the files 2020-05-05 09:15:16 +02:00
Runtime LibJS: Add String.raw 2020-05-07 23:05:55 +02:00
Tests LibJS: Limit scope of 'for' loop variables 2020-05-07 23:31:49 +02:00
AST.cpp LibJS: Limit scope of 'for' loop variables 2020-05-07 23:31:49 +02:00
AST.h LibJS: Add raw strings to tagged template literals 2020-05-07 23:05:55 +02:00
Console.cpp LibJS: Implement ConsoleClient 2020-05-05 09:15:16 +02:00
Console.h LibJS: Implement ConsoleClient 2020-05-05 09:15:16 +02:00
Forward.h LibJS: Add Reference class to represent a base.property reference 2020-04-28 15:07:08 +02:00
Interpreter.cpp LibJS: Add some helpers and use them to re-implement Console functions 2020-05-05 09:15:16 +02:00
Interpreter.h LibJS: Add some helpers and use them to re-implement Console functions 2020-05-05 09:15:16 +02:00
Lexer.cpp LibJS: Implement exponentiation assignment operator (**=) 2020-05-05 11:12:27 +02:00
Lexer.h LibJS: Add template literals 2020-05-04 16:46:31 +02:00
Makefile LibJS: Start implementing a Console class for the interpreter 2020-05-02 11:41:35 +02:00
Parser.cpp LibJS: Limit scope of 'for' loop variables 2020-05-07 23:31:49 +02:00
Parser.h LibJS: Add raw strings to tagged template literals 2020-05-07 23:05:55 +02:00
Token.cpp LibJS: Add template literals 2020-05-04 16:46:31 +02:00
Token.h LibJS: Implement exponentiation assignment operator (**=) 2020-05-05 11:12:27 +02:00