From 83ea7bb9e73f91de2cc4940f384414be61eaafd0 Mon Sep 17 00:00:00 2001 From: 0xtechnobabble <0xtechnobabble@protonmail.com> Date: Fri, 13 Mar 2020 20:16:37 +0200 Subject: [PATCH] LibJS: Don't allow the redeclaration of a `var` variable using let/const Previously, we were allowing the redeclaration of a variable with `let` or `const` if it was declared initially using `var`, we should not tolerate any form of variable redeclaration using let/const. --- Libraries/LibJS/Interpreter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/LibJS/Interpreter.cpp b/Libraries/LibJS/Interpreter.cpp index 91153a538f..99049a36c4 100644 --- a/Libraries/LibJS/Interpreter.cpp +++ b/Libraries/LibJS/Interpreter.cpp @@ -96,7 +96,7 @@ void Interpreter::declare_variable(String name, DeclarationType declaration_type break; case DeclarationType::Let: case DeclarationType::Const: - if (m_scope_stack.last().variables.get(name).has_value() && m_scope_stack.last().variables.get(name).value().declaration_type != DeclarationType::Var) + if (m_scope_stack.last().variables.get(name).has_value()) ASSERT_NOT_REACHED(); m_scope_stack.last().variables.set(move(name), { js_undefined(), declaration_type });