mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:18:11 +00:00
LibJS: Fix "use strict" directive false positives
By having the "is this a use strict directive?" logic in parse_string_literal() we would apply it to *any* string literal, which is incorrect and would lead to false positives - e.g.: "use strict" + 1 `"use strict"` "\123"; ({"use strict": ...}) Relevant part from the spec which is now implemented properly: [...] and where each ExpressionStatement in the sequence consists entirely of a StringLiteral token [...] I also got rid of UseStrictDirectiveState which is not needed anymore. Fixes #3903.
This commit is contained in:
parent
21912123c4
commit
9e80c67608
4 changed files with 54 additions and 55 deletions
|
@ -164,12 +164,6 @@ private:
|
|||
void save_state();
|
||||
void load_state();
|
||||
|
||||
enum class UseStrictDirectiveState {
|
||||
None,
|
||||
Looking,
|
||||
Found,
|
||||
};
|
||||
|
||||
struct ParserState {
|
||||
Lexer m_lexer;
|
||||
Token m_current_token;
|
||||
|
@ -177,7 +171,6 @@ private:
|
|||
Vector<NonnullRefPtrVector<VariableDeclaration>> m_var_scopes;
|
||||
Vector<NonnullRefPtrVector<VariableDeclaration>> m_let_scopes;
|
||||
Vector<NonnullRefPtrVector<FunctionDeclaration>> m_function_scopes;
|
||||
UseStrictDirectiveState m_use_strict_directive { UseStrictDirectiveState::None };
|
||||
HashTable<StringView> m_labels_in_scope;
|
||||
bool m_strict_mode { false };
|
||||
bool m_allow_super_property_lookup { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue