Bug 1317309: Throw a TypeError when passing a Symbol value to ToAtom

Issue #78
[Depends on] Bug 883377: Implement ES6 function "name" property
semantics
This commit is contained in:
janekptacijarabaci 2018-03-19 15:18:37 +01:00 • committed by Roy Tam
commit 3b34f87a5b
4 changed files with 45 additions and 3 deletions

View file

@ -510,6 +510,14 @@ ToAtomSlow(ExclusiveContext* cx, typename MaybeRooted<Value, allowGC>::HandleTyp
return v.toBoolean() ? cx->names().true_ : cx->names().false_;
if (v.isNull())
return cx->names().null;
if (v.isSymbol()) {
if (cx->shouldBeJSContext() && allowGC) {
JS_ReportErrorNumberASCII(cx->asJSContext(), GetErrorMessage, nullptr,
JSMSG_SYMBOL_TO_STRING);
}
return nullptr;
}
MOZ_ASSERT(v.isUndefined());
return cx->names().undefined;
}