diff options
author | Idan Horowitz <idan.horowitz@gmail.com> | 2021-07-01 02:04:06 +0300 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-07-01 09:55:50 +0100 |
commit | 6ef56f79bd6d59880f89d7de134702b8dea06f26 (patch) | |
tree | 0a46fda222fd989807157d425ff3c08a10270c19 /Userland | |
parent | 9295f1936c6119b46893ba6325a795502550c52d (diff) | |
download | serenity-6ef56f79bd6d59880f89d7de134702b8dea06f26.zip |
LibJS: Stop coercing Date.prototype[Symbol.toPrimitive] hint to string
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/DatePrototype.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp index 8456b6f082..317dbb2f45 100644 --- a/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/DatePrototype.cpp @@ -860,12 +860,15 @@ JS_DEFINE_NATIVE_FUNCTION(DatePrototype::symbol_to_primitive) { auto this_value = vm.this_value(global_object); if (!this_value.is_object()) { - vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject); + vm.throw_exception<TypeError>(global_object, ErrorType::NotAnObject, this_value.to_string_without_side_effects()); return {}; } - auto hint = vm.argument(0).to_string(global_object); - if (vm.exception()) + auto hint_value = vm.argument(0); + if (!hint_value.is_string()) { + vm.throw_exception<TypeError>(global_object, ErrorType::InvalidHint, hint_value.to_string_without_side_effects()); return {}; + } + auto& hint = hint_value.as_string().string(); Value::PreferredType try_first; if (hint == "string" || hint == "default") { try_first = Value::PreferredType::String; |