summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-17 20:57:29 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-17 20:57:29 +0100
commit60e630d5a0f1f075ebcc2e4541858aff9ad70604 (patch)
tree36c561a226550b10f2fcd7b32c1df9cfa8af2057 /Userland/Libraries/LibJS/Runtime
parentd792200a5531bf9872e19c7c7a3ba4c865ad43b6 (diff)
downloadserenity-60e630d5a0f1f075ebcc2e4541858aff9ad70604.zip
LibJS: eval(x) should return x without evaluation if x is not a string
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index e7e0ac9b00..6c2bc8d31a 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -316,10 +316,10 @@ Value GlobalObject::get_this_binding(GlobalObject&) const
JS_DEFINE_NATIVE_FUNCTION(GlobalObject::eval)
{
- auto code = vm.argument(0).to_string(global_object);
- if (code.is_null())
- return {};
- JS::Parser parser { JS::Lexer { code } };
+ if (!vm.argument(0).is_string())
+ return vm.argument(0);
+ auto& code_string = vm.argument(0).as_string();
+ JS::Parser parser { JS::Lexer { code_string.string() } };
auto program = parser.parse_program();
if (parser.has_errors()) {