зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1683784 - Remove extra '#' in read-only error message for SymbolCode::PrivateNameSymbol. r=mgaudet
Differential Revision: https://phabricator.services.mozilla.com/D102257
This commit is contained in:
Родитель
2dc3194ddb
Коммит
795a0e1d44
|
@ -0,0 +1,12 @@
|
|||
// |jit-test| --enable-private-methods;
|
||||
|
||||
class C {
|
||||
#x() { }
|
||||
constructor() { this.#x = 1; }
|
||||
}
|
||||
|
||||
try {
|
||||
new C
|
||||
} catch (e) {
|
||||
assertEq(e.message, "#x is read-only")
|
||||
}
|
|
@ -70,30 +70,28 @@ static JSString* SymbolToSource(JSContext* cx, JS::Symbol* symbol) {
|
|||
return desc;
|
||||
}
|
||||
|
||||
JSStringBuilder buf(cx);
|
||||
if (code == SymbolCode::PrivateNameSymbol) {
|
||||
MOZ_ASSERT(desc);
|
||||
if (!buf.append('#') || !buf.append(desc)) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(code == SymbolCode::InSymbolRegistry ||
|
||||
code == SymbolCode::UniqueSymbol);
|
||||
return desc;
|
||||
}
|
||||
|
||||
if (code == SymbolCode::InSymbolRegistry ? !buf.append("Symbol.for(")
|
||||
: !buf.append("Symbol(")) {
|
||||
return nullptr;
|
||||
}
|
||||
if (desc) {
|
||||
UniqueChars quoted = QuoteString(cx, desc, '"');
|
||||
if (!quoted || !buf.append(quoted.get(), strlen(quoted.get()))) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!buf.append(')')) {
|
||||
MOZ_ASSERT(code == SymbolCode::InSymbolRegistry ||
|
||||
code == SymbolCode::UniqueSymbol);
|
||||
|
||||
JSStringBuilder buf(cx);
|
||||
if (code == SymbolCode::InSymbolRegistry ? !buf.append("Symbol.for(")
|
||||
: !buf.append("Symbol(")) {
|
||||
return nullptr;
|
||||
}
|
||||
if (desc) {
|
||||
UniqueChars quoted = QuoteString(cx, desc, '"');
|
||||
if (!quoted || !buf.append(quoted.get(), strlen(quoted.get()))) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
if (!buf.append(')')) {
|
||||
return nullptr;
|
||||
}
|
||||
return buf.finishString();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче