From 668e73df8ad13ced2ae1086e660c7ffc7191ce32 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Sep 2020 19:16:34 +0200 Subject: [PATCH] LibJS: Make Interpreter::in_strict_mode() work outside of scope This one is a little weird. I don't know why it's okay for this function to assume that there is a current scope on the scope stack when it can be called during global object initialization etc. For now, just make it say "we are in strict mode" when there is no currently active scope. --- Libraries/LibJS/Interpreter.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Libraries/LibJS/Interpreter.h b/Libraries/LibJS/Interpreter.h index 914876e94a..a9e3eeaac3 100644 --- a/Libraries/LibJS/Interpreter.h +++ b/Libraries/LibJS/Interpreter.h @@ -152,7 +152,12 @@ public: const LexicalEnvironment* current_environment() const { return m_call_stack.last().environment; } LexicalEnvironment* current_environment() { return m_call_stack.last().environment; } - bool in_strict_mode() const { return m_scope_stack.last().scope_node->in_strict_mode(); } + bool in_strict_mode() const + { + if (m_scope_stack.is_empty()) + return true; + return m_scope_stack.last().scope_node->in_strict_mode(); + } template void for_each_argument(Callback callback)