Skip to content

Commit 36fc51b

Browse files
committed
[1.6>1.7] [MERGE #3412 @curtisman] Fix Issue #3368: Symbol.species.toString() shouldn't have bracket around the name
Merge pull request #3412 from curtisman:fix3368
2 parents cb5557f + 6ca7bbb commit 36fc51b

File tree

7 files changed

+30
-48
lines changed

7 files changed

+30
-48
lines changed

lib/Runtime/Base/JnDirectFields.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ENTRY_SYMBOL(_symbolMatch, _u("Symbol.match"))
3838
ENTRY_SYMBOL(_symbolReplace, _u("Symbol.replace"))
3939
ENTRY_SYMBOL(_symbolSearch, _u("Symbol.search"))
4040
ENTRY_SYMBOL(_symbolSplit, _u("Symbol.split"))
41-
ENTRY_SYMBOL(_symbolSpecies, _u("[Symbol.species]"))
41+
ENTRY_SYMBOL(_symbolSpecies, _u("Symbol.species"))
4242
ENTRY_SYMBOL(_symbolToPrimitive, _u("Symbol.toPrimitive"))
4343
ENTRY_SYMBOL(_symbolToStringTag, _u("Symbol.toStringTag"))
4444
ENTRY_SYMBOL(_symbolUnscopables, _u("Symbol.unscopables"))

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,10 +1640,7 @@ namespace Js
16401640

16411641
library->AddMember(arrayConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
16421642
library->AddMember(arrayConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayPrototype, PropertyNone);
1643-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1644-
{
1645-
library->AddAccessorsToLibraryObject(arrayConstructor, PropertyIds::_symbolSpecies, &JavascriptArray::EntryInfo::GetterSymbolSpecies, nullptr);
1646-
}
1643+
library->AddSpeciesAccessorsToLibraryObject(arrayConstructor, &JavascriptArray::EntryInfo::GetterSymbolSpecies);
16471644

16481645
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
16491646
{
@@ -1807,8 +1804,7 @@ namespace Js
18071804
JavascriptLibrary* library = sharedArrayBufferConstructor->GetLibrary();
18081805
library->AddMember(sharedArrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
18091806
library->AddMember(sharedArrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->sharedArrayBufferPrototype, PropertyNone);
1810-
1811-
library->AddAccessorsToLibraryObject(sharedArrayBufferConstructor, PropertyIds::_symbolSpecies, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
1807+
library->AddSpeciesAccessorsToLibraryObject(sharedArrayBufferConstructor, &SharedArrayBuffer::EntryInfo::GetterSymbolSpecies);
18121808

18131809
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
18141810
{
@@ -1877,11 +1873,7 @@ namespace Js
18771873
JavascriptLibrary* library = arrayBufferConstructor->GetLibrary();
18781874
library->AddMember(arrayBufferConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
18791875
library->AddMember(arrayBufferConstructor, PropertyIds::prototype, scriptContext->GetLibrary()->arrayBufferPrototype, PropertyNone);
1880-
1881-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1882-
{
1883-
library->AddAccessorsToLibraryObject(arrayBufferConstructor, PropertyIds::_symbolSpecies, &ArrayBuffer::EntryInfo::GetterSymbolSpecies, nullptr);
1884-
}
1876+
library->AddSpeciesAccessorsToLibraryObject(arrayBufferConstructor, &ArrayBuffer::EntryInfo::GetterSymbolSpecies);
18851877

18861878
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
18871879
{
@@ -1991,10 +1983,7 @@ namespace Js
19911983

19921984
library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::from, &TypedArrayBase::EntryInfo::From, 1);
19931985
library->AddFunctionToLibraryObject(typedArrayConstructor, PropertyIds::of, &TypedArrayBase::EntryInfo::Of, 0);
1994-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
1995-
{
1996-
library->AddAccessorsToLibraryObject(typedArrayConstructor, PropertyIds::_symbolSpecies, &TypedArrayBase::EntryInfo::GetterSymbolSpecies, nullptr);
1997-
}
1986+
library->AddSpeciesAccessorsToLibraryObject(typedArrayConstructor, &TypedArrayBase::EntryInfo::GetterSymbolSpecies);
19981987

19991988
typedArrayConstructor->SetHasNoEnumerableProperties(true);
20001989

@@ -2352,11 +2341,7 @@ namespace Js
23522341
ScriptContext* scriptContext = promiseConstructor->GetScriptContext();
23532342
library->AddMember(promiseConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(1), PropertyNone);
23542343
library->AddMember(promiseConstructor, PropertyIds::prototype, library->promisePrototype, PropertyNone);
2355-
2356-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
2357-
{
2358-
library->AddAccessorsToLibraryObject(promiseConstructor, PropertyIds::_symbolSpecies, &JavascriptPromise::EntryInfo::GetterSymbolSpecies, nullptr);
2359-
}
2344+
library->AddSpeciesAccessorsToLibraryObject(promiseConstructor, &JavascriptPromise::EntryInfo::GetterSymbolSpecies);
23602345

23612346
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
23622347
{
@@ -4425,11 +4410,7 @@ namespace Js
44254410
// so that the update is in sync with profiler
44264411
library->AddMember(regexConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(2), PropertyNone);
44274412
library->AddMember(regexConstructor, PropertyIds::prototype, library->regexPrototype, PropertyNone);
4428-
4429-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4430-
{
4431-
library->AddAccessorsToLibraryObject(regexConstructor, PropertyIds::_symbolSpecies, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies, nullptr);
4432-
}
4413+
library->AddSpeciesAccessorsToLibraryObject(regexConstructor, &JavascriptRegExp::EntryInfo::GetterSymbolSpecies);
44334414

44344415
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
44354416
{
@@ -4657,11 +4638,7 @@ namespace Js
46574638
ScriptContext* scriptContext = mapConstructor->GetScriptContext();
46584639
library->AddMember(mapConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
46594640
library->AddMember(mapConstructor, PropertyIds::prototype, library->mapPrototype, PropertyNone);
4660-
4661-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4662-
{
4663-
library->AddAccessorsToLibraryObject(mapConstructor, PropertyIds::_symbolSpecies, &JavascriptMap::EntryInfo::GetterSymbolSpecies, nullptr);
4664-
}
4641+
library->AddSpeciesAccessorsToLibraryObject(mapConstructor, &JavascriptMap::EntryInfo::GetterSymbolSpecies);
46654642

46664643
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
46674644
{
@@ -4716,11 +4693,7 @@ namespace Js
47164693
ScriptContext* scriptContext = setConstructor->GetScriptContext();
47174694
library->AddMember(setConstructor, PropertyIds::length, TaggedInt::ToVarUnchecked(0), PropertyNone);
47184695
library->AddMember(setConstructor, PropertyIds::prototype, library->setPrototype, PropertyNone);
4719-
4720-
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
4721-
{
4722-
library->AddAccessorsToLibraryObject(setConstructor, PropertyIds::_symbolSpecies, &JavascriptSet::EntryInfo::GetterSymbolSpecies, nullptr);
4723-
}
4696+
library->AddSpeciesAccessorsToLibraryObject(setConstructor, &JavascriptSet::EntryInfo::GetterSymbolSpecies);
47244697

47254698
if (scriptContext->GetConfig()->IsES6FunctionNameEnabled())
47264699
{
@@ -5145,6 +5118,14 @@ namespace Js
51455118
AddAccessorsToLibraryObject(object, propertyId, getterFunction, setterFunction);
51465119
}
51475120

5121+
void JavascriptLibrary::AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo)
5122+
{
5123+
if (scriptContext->GetConfig()->IsES6SpeciesEnabled())
5124+
{
5125+
AddAccessorsToLibraryObjectWithName(object, PropertyIds::_symbolSpecies, PropertyIds::_RuntimeFunctionNameId_species, getterFunctionInfo, nullptr);
5126+
}
5127+
}
5128+
51485129
RuntimeFunction* JavascriptLibrary::CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo)
51495130
{
51505131
Var name_withGetPrefix = LiteralString::Concat(LiteralString::NewCopySz(_u("get "), scriptContext), scriptContext->GetPropertyString(nameId));

lib/Runtime/Library/JavascriptLibrary.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,7 @@ namespace Js
574574
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunctionInfo);
575575
void AddAccessorsToLibraryObject(DynamicObject* object, PropertyId propertyId, RecyclableObject * getterFunction, RecyclableObject * setterFunction);
576576
void AddAccessorsToLibraryObjectWithName(DynamicObject* object, PropertyId propertyId, PropertyId nameId, FunctionInfo * getterFunctionInfo, FunctionInfo * setterFunction);
577+
void AddSpeciesAccessorsToLibraryObject(DynamicObject* object, FunctionInfo * getterFunctionInfo);
577578
RuntimeFunction * CreateGetterFunction(PropertyId nameId, FunctionInfo* functionInfo);
578579
RuntimeFunction * CreateSetterFunction(PropertyId nameId, FunctionInfo* functionInfo);
579580

test/DebuggerCommon/ES6_proto_invalidation.js.dbg.baseline

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
"#__proto__": "function <large string>",
368368
"length": "number 1",
369369
"prototype": "Array []",
370-
"[Symbol.species]": "function <large string>",
370+
"Symbol.species": "function <large string>",
371371
"name": "string Array",
372372
"isArray": "function <large string>",
373373
"from": "function <large string>",
@@ -646,7 +646,7 @@
646646
"#__proto__": "function <large string>",
647647
"length": "number 1",
648648
"prototype": "Array []",
649-
"[Symbol.species]": "function <large string>",
649+
"Symbol.species": "function <large string>",
650650
"name": "string Array",
651651
"isArray": "function <large string>",
652652
"from": "function <large string>",
@@ -884,4 +884,4 @@
884884
}
885885
}
886886
}
887-
]
887+
]

test/DebuggerCommon/TypedArray.js.dbg.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
"caller": "object null",
6868
"arguments": "object null"
6969
},
70-
"[Symbol.species]": {
70+
"Symbol.species": {
7171
"#__proto__": "function function() {\n [native code]\n}",
7272
"length": "number 3",
7373
"name": "string Int8Array",
@@ -348,4 +348,4 @@
348348
}
349349
]
350350
}
351-
]
351+
]

test/DebuggerCommon/bug_543550.js.dbg.baseline

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"#__proto__": "function function() {\n [native code]\n}",
2121
"length": "number 0",
2222
"prototype": "Object {...}",
23-
"[Symbol.species]": "function function Map() { [native code] }",
23+
"Symbol.species": "function function Map() { [native code] }",
2424
"name": "string Map",
2525
"caller": "object null",
2626
"arguments": "object null"
@@ -131,4 +131,4 @@
131131
}
132132
}
133133
}
134-
]
134+
]

test/DebuggerCommon/frames_values_mapES6.js.dbg.baseline

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"#__proto__": "function <large string>",
2222
"length": "number 0",
2323
"prototype": "Object {...}",
24-
"[Symbol.species]": "function <large string>",
24+
"Symbol.species": "function <large string>",
2525
"name": "string Map",
2626
"caller": "object null",
2727
"arguments": "object null"
@@ -187,7 +187,7 @@
187187
"#__proto__": "function <large string>",
188188
"length": "number 0",
189189
"prototype": "Object {...}",
190-
"[Symbol.species]": "function <large string>",
190+
"Symbol.species": "function <large string>",
191191
"name": "string Map",
192192
"caller": "object null",
193193
"arguments": "object null"
@@ -291,7 +291,7 @@
291291
"#__proto__": "function <large string>",
292292
"length": "number 0",
293293
"prototype": "Object {...}",
294-
"[Symbol.species]": "function <large string>",
294+
"Symbol.species": "function <large string>",
295295
"name": "string Map",
296296
"caller": "object null",
297297
"arguments": "object null"
@@ -457,7 +457,7 @@
457457
"#__proto__": "function <large string>",
458458
"length": "number 0",
459459
"prototype": "Object {...}",
460-
"[Symbol.species]": "function <large string>",
460+
"Symbol.species": "function <large string>",
461461
"name": "string Map",
462462
"caller": "object null",
463463
"arguments": "object null"
@@ -539,4 +539,4 @@
539539
}
540540
}
541541
}
542-
]
542+
]

0 commit comments

Comments
 (0)