Skip to content

Commit 48d00f1

Browse files
Kevin SmithKevin Smith
authored andcommitted
Give JavascriptRegExpConstructor the correct ConstructorCache
1 parent 9240377 commit 48d00f1

File tree

4 files changed

+15
-4
lines changed

4 files changed

+15
-4
lines changed

lib/Runtime/Library/JavascriptLibrary.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,10 @@ namespace Js
15201520
AddFunction(globalObject, PropertyIds::String, stringConstructor);
15211521
regexConstructorType = DynamicType::New(scriptContext, TypeIds_Function, functionPrototype, JavascriptRegExp::NewInstance,
15221522
DeferredTypeHandler<InitializeRegexConstructor>::GetDefaultInstance());
1523-
regexConstructor = RecyclerNewEnumClass(recycler, EnumFunctionClass, JavascriptRegExpConstructor, regexConstructorType);
1523+
regexConstructor = RecyclerNewEnumClass(recycler, EnumFunctionClass,
1524+
JavascriptRegExpConstructor,
1525+
regexConstructorType,
1526+
builtInConstructorCache);
15241527
AddFunction(globalObject, PropertyIds::RegExp, regexConstructor);
15251528

15261529
arrayBufferConstructor = CreateBuiltinConstructor(&ArrayBuffer::EntryInfo::NewInstance,

lib/Runtime/Library/JavascriptRegExpConstructor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ namespace Js
1414
const int JavascriptRegExpConstructor::NumCtorCaptures;
1515
#endif
1616

17-
JavascriptRegExpConstructor::JavascriptRegExpConstructor(DynamicType * type) :
18-
RuntimeFunction(type, &JavascriptRegExp::EntryInfo::NewInstance),
17+
JavascriptRegExpConstructor::JavascriptRegExpConstructor(DynamicType* type, ConstructorCache* cache) :
18+
RuntimeFunction(type, &JavascriptRegExp::EntryInfo::NewInstance, cache),
1919
reset(false),
2020
invalidatedLastMatch(false),
2121
lastPattern(nullptr),

lib/Runtime/Library/JavascriptRegExpConstructor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Js
2222
DEFINE_VTABLE_CTOR_MEMBER_INIT(JavascriptRegExpConstructor, RuntimeFunction, lastMatch);
2323

2424
public:
25-
JavascriptRegExpConstructor(DynamicType * type);
25+
JavascriptRegExpConstructor(DynamicType* type, ConstructorCache* cache);
2626

2727
virtual PropertyQueryFlags HasPropertyQuery(PropertyId propertyId, _Inout_opt_ PropertyValueInfo* info) override;
2828
virtual PropertyQueryFlags GetPropertyQuery(Var originalInstance, PropertyId propertyId, Var* value, PropertyValueInfo* info, ScriptContext* requestContext) override;

test/Bugs/misc_bugs.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ var tests = [
138138
} catch(e) { }
139139
}
140140
},
141+
{
142+
name: "Using RegExp as newTarget should not assert",
143+
body: function() {
144+
var v0 = function() { this.a; };
145+
var v1 = class extends v0 { constructor() { super(); } };
146+
Reflect.construct(v1, [], RegExp);
147+
}
148+
},
141149
{
142150
name: "getPrototypeOf Should not be called when set as prototype",
143151
body: function () {

0 commit comments

Comments
 (0)