diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp index c5233815566..b4eac8d4570 100644 --- a/Userland/Libraries/LibJS/AST.cpp +++ b/Userland/Libraries/LibJS/AST.cpp @@ -669,7 +669,7 @@ Reference Expression::to_reference(Interpreter&, GlobalObject&) const Reference Identifier::to_reference(Interpreter& interpreter, GlobalObject&) const { - return interpreter.vm().get_reference(string()); + return interpreter.vm().resolve_binding(string()); } Reference MemberExpression::to_reference(Interpreter& interpreter, GlobalObject& global_object) const diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp index 80427df7c01..cd40bd14ccc 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.cpp +++ b/Userland/Libraries/LibJS/Runtime/VM.cpp @@ -392,8 +392,11 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object) return value; } -Reference VM::get_reference(const FlyString& name) +// 9.4.2 ResolveBinding ( name [ , env ] ), https://tc39.es/ecma262/#sec-resolvebinding +Reference VM::resolve_binding(FlyString const& name) { + // FIXME: This implementation of ResolveBinding is non-conforming. + for (auto* environment_record = lexical_environment(); environment_record && environment_record->outer_environment(); environment_record = environment_record->outer_environment()) { auto possible_match = environment_record->get_from_environment_record(name); if (possible_match.has_value()) diff --git a/Userland/Libraries/LibJS/Runtime/VM.h b/Userland/Libraries/LibJS/Runtime/VM.h index b49d1468aa4..1a907669913 100644 --- a/Userland/Libraries/LibJS/Runtime/VM.h +++ b/Userland/Libraries/LibJS/Runtime/VM.h @@ -202,7 +202,7 @@ public: void assign(const FlyString& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr); void assign(const NonnullRefPtr& target, Value, GlobalObject&, bool first_assignment = false, EnvironmentRecord* specific_scope = nullptr); - Reference get_reference(const FlyString& name); + Reference resolve_binding(FlyString const&); template void throw_exception(GlobalObject& global_object, Args&&... args)