Fix lexical scoping between scripts (#3558)
This change fixes the handling of lexical blocks when executing multiple scripts, and also fixes a few issues with module environments. After this change, all script files will run in the same context and will have access to lexically scoped global variables of previous scripts, and module environments will no longer have a bound global 'this' value. The REPL implementation in main-unix is also fixed to correctly handle lexically scoped variables. Fixes #3561. JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
@@ -58,7 +58,7 @@ typedef enum
|
||||
PARSER_DEBUGGER_BREAKPOINT_APPENDED = (1u << 11), /**< pending (unsent) breakpoint
|
||||
* info is available */
|
||||
#if ENABLED (JERRY_ES2015)
|
||||
PARSER_INSIDE_BLOCK = (1u << 12), /**< script has a lexical environment for let and const */
|
||||
PARSER_LEXICAL_BLOCK_NEEDED = (1u << 12), /**< script needs a lexical environment for let and const */
|
||||
PARSER_IS_ARROW_FUNCTION = (1u << 13), /**< an arrow function is parsed */
|
||||
PARSER_IS_GENERATOR_FUNCTION = (1u << 14), /**< a generator function is parsed */
|
||||
PARSER_IS_ASYNC_FUNCTION = (1u << 15), /**< an async function is parsed */
|
||||
@@ -726,6 +726,7 @@ bool scanner_is_context_needed (parser_context_t *context_p);
|
||||
bool scanner_is_global_context_needed (parser_context_t *context_p);
|
||||
bool scanner_scope_find_let_declaration (parser_context_t *context_p, lexer_lit_location_t *literal_p);
|
||||
bool scanner_try_scan_new_target (parser_context_t *context_p);
|
||||
void scanner_check_variables (parser_context_t *context_p);
|
||||
#endif /* ENABLED (JERRY_ES2015) */
|
||||
void scanner_create_variables (parser_context_t *context_p, uint32_t option_flags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user