1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibJS/Bytecode: Make typeof return "undefined" on unresolvable IDs

Previously it would throw instead of returning "undefined" for
`typeof Identifier` if Identifier does not exist.
This commit is contained in:
Luke Wilde 2022-06-11 23:12:22 +01:00 committed by Ali Mohammad Pur
parent c0fadfb9b7
commit 482a827346
4 changed files with 55 additions and 1 deletions

View file

@ -910,6 +910,22 @@ public:
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
};
class TypeofVariable final : public Instruction {
public:
explicit TypeofVariable(IdentifierTableIndex identifier)
: Instruction(Type::TypeofVariable)
, m_identifier(identifier)
{
}
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
String to_string_impl(Bytecode::Executable const&) const;
void replace_references_impl(BasicBlock const&, BasicBlock const&) { }
private:
IdentifierTableIndex m_identifier;
};
}
namespace JS::Bytecode {