LibJS: Throw TypeError when coercing symbol to number

This commit is contained in:
Linus Groh 2020-05-18 00:54:10 +01:00 committed by Andreas Kling
commit 4569e88bea
Notes: sideshowbarker 2024-07-19 06:32:18 +09:00
2 changed files with 8 additions and 9 deletions

View file

@ -231,8 +231,8 @@ Value Value::to_number(Interpreter& interpreter) const
return Value(parsed_double);
}
case Type::Symbol:
// FIXME: Get access to the interpreter and throw a TypeError
ASSERT_NOT_REACHED();
interpreter.throw_exception<TypeError>("Can't convert symbol to number");
return {};
case Type::Object:
auto primitive = m_value.as_object->to_primitive(Object::PreferredType::Number);
if (interpreter.exception())