mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1164777 - Part 2: Make super.prop parse inside inside eval inside arrow functions. (r=shu)
This commit is contained in:
parent
fcf7797b5f
commit
585898080e
@ -283,12 +283,8 @@ frontend::CompileScript(ExclusiveContext* cx, LifoAlloc* alloc, HandleObject sco
|
||||
return nullptr;
|
||||
|
||||
bool savedCallerFun = evalCaller && evalCaller->functionOrCallerFunction();
|
||||
bool allowSuperProperty = savedCallerFun &&
|
||||
evalCaller->functionOrCallerFunction()->allowSuperProperty();
|
||||
|
||||
Directives directives(options.strictOption);
|
||||
GlobalSharedContext globalsc(cx, directives, evalStaticScope, options.extraWarningsOption,
|
||||
allowSuperProperty);
|
||||
GlobalSharedContext globalsc(cx, directives, evalStaticScope, options.extraWarningsOption);
|
||||
|
||||
Rooted<JSScript*> script(cx, JSScript::Create(cx, evalStaticScope, savedCallerFun,
|
||||
options, staticLevel, sourceObject, 0,
|
||||
|
@ -700,8 +700,7 @@ Parser<ParseHandler>::parse(JSObject* chain)
|
||||
Directives directives(options().strictOption);
|
||||
GlobalSharedContext globalsc(context, directives,
|
||||
/* staticEvalScope = */ nullptr,
|
||||
options().extraWarningsOption,
|
||||
/* allowSuperProperty = */ false);
|
||||
options().extraWarningsOption);
|
||||
ParseContext<ParseHandler> globalpc(this, /* parent = */ nullptr, ParseHandler::null(),
|
||||
&globalsc, /* newDirectives = */ nullptr,
|
||||
/* staticLevel = */ 0, /* bodyid = */ 0,
|
||||
|
@ -237,20 +237,29 @@ class GlobalSharedContext : public SharedContext
|
||||
{
|
||||
private:
|
||||
Handle<StaticEvalObject*> staticEvalScope_;
|
||||
bool allowSuperProperty_;
|
||||
|
||||
public:
|
||||
GlobalSharedContext(ExclusiveContext* cx,
|
||||
Directives directives, Handle<StaticEvalObject*> staticEvalScope,
|
||||
bool extraWarnings, bool allowSuperProperty)
|
||||
bool extraWarnings)
|
||||
: SharedContext(cx, directives, extraWarnings),
|
||||
staticEvalScope_(staticEvalScope),
|
||||
allowSuperProperty_(allowSuperProperty)
|
||||
staticEvalScope_(staticEvalScope)
|
||||
{}
|
||||
|
||||
ObjectBox* toObjectBox() { return nullptr; }
|
||||
bool allowSuperProperty() const { return allowSuperProperty_; }
|
||||
HandleObject evalStaticScope() const { return staticEvalScope_; }
|
||||
|
||||
bool allowSuperProperty() const {
|
||||
StaticScopeIter<CanGC> it(context, staticEvalScope_);
|
||||
for (; !it.done(); it++) {
|
||||
if (it.type() == StaticScopeIter<CanGC>::Function &&
|
||||
!it.fun().isArrow())
|
||||
{
|
||||
return it.fun().allowSuperProperty();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class FunctionBox : public ObjectBox, public SharedContext
|
||||
|
11
js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js
Normal file
11
js/src/tests/ecma_6/Class/superPropEvalInsideArrow.js
Normal file
@ -0,0 +1,11 @@
|
||||
class foo {
|
||||
constructor() { }
|
||||
|
||||
method() {
|
||||
return (() => eval('super.toString'));
|
||||
}
|
||||
}
|
||||
assertEq(new foo().method()(), Object.prototype.toString);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(0,0,"OK");
|
13
js/src/tests/ecma_6/Class/superPropEvalInsideNested.js
Normal file
13
js/src/tests/ecma_6/Class/superPropEvalInsideNested.js
Normal file
@ -0,0 +1,13 @@
|
||||
// It's invalid to eval super.prop inside a nested non-method, even if it
|
||||
// appears inside a method definition
|
||||
assertThrowsInstanceOf(() =>
|
||||
({
|
||||
method() {
|
||||
(function () {
|
||||
eval('super.toString');
|
||||
})();
|
||||
}
|
||||
}).method(), SyntaxError);
|
||||
|
||||
if (typeof reportCompare === 'function')
|
||||
reportCompare(0,0,"OK");
|
Loading…
Reference in New Issue
Block a user