mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1199422 - Stop pattern matching class-constructors in String#replace and Array#sort. r=efaust
This commit is contained in:
parent
a10e6c590b
commit
a06bb506b3
@ -1653,7 +1653,7 @@ MatchNumericComparator(JSContext* cx, const Value& v)
|
||||
return Match_None;
|
||||
|
||||
JSFunction* fun = &obj.as<JSFunction>();
|
||||
if (!fun->isInterpreted())
|
||||
if (!fun->isInterpreted() || fun->isClassConstructor())
|
||||
return Match_None;
|
||||
|
||||
JSScript* script = fun->getOrCreateScript(cx);
|
||||
|
@ -3485,7 +3485,7 @@ LambdaIsGetElem(JSContext* cx, JSObject& lambda, MutableHandleNativeObject pobj)
|
||||
return true;
|
||||
|
||||
RootedFunction fun(cx, &lambda.as<JSFunction>());
|
||||
if (!fun->isInterpreted())
|
||||
if (!fun->isInterpreted() || fun->isClassConstructor())
|
||||
return true;
|
||||
|
||||
JSScript* script = fun->getOrCreateScript(cx);
|
||||
|
34
js/src/tests/ecma_6/Class/bytecodePatternMatching.js
Normal file
34
js/src/tests/ecma_6/Class/bytecodePatternMatching.js
Normal file
@ -0,0 +1,34 @@
|
||||
// Constructors can't be called so we can't pattern match
|
||||
// them in replace and sort.
|
||||
var test = `
|
||||
function a() {
|
||||
var b = {a: "A"};
|
||||
|
||||
class X {
|
||||
constructor(a) {
|
||||
return b[a]
|
||||
}
|
||||
};
|
||||
|
||||
assertThrowsInstanceOf(() => "a".replace(/a/, X), TypeError);
|
||||
}
|
||||
|
||||
function b() {
|
||||
class X {
|
||||
constructor(x, y) {
|
||||
return x - y;
|
||||
}
|
||||
}
|
||||
|
||||
assertThrowsInstanceOf(() => [1, 2, 3].sort(X), TypeError);
|
||||
}
|
||||
|
||||
a();
|
||||
b();
|
||||
`;
|
||||
|
||||
if (classesEnabled())
|
||||
eval(test);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0, 0, "OK");
|
Loading…
Reference in New Issue
Block a user