[Webkit-unassigned] [Bug 157872] Our parser doesn't properly parse default parameter expressions in a class method

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jun 1 00:38:20 PDT 2016


https://bugs.webkit.org/show_bug.cgi?id=157872

--- Comment #19 from Caio Lima <ticaiolima at gmail.com> ---
(In reply to comment #18)
> Comment on attachment 280110 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280110&action=review
> 
> r=me wth comments
> 
> > Source/JavaScriptCore/parser/Parser.cpp:1929
> > +    functionScope->setExpectedSuperBinding(expectedSuperBinding);
> 
> Can you remove the duplicate call below to setExpectedSuperKind(...)?

Sure. Actually I can just remove the call on line :1951 (inside loadCachedFunction), since the "expectedSuperBinding" can change "if (m_defaultConstructorKind != ConstructorKind::None)".

> Also, I wonder if we should be calling setConstructKind up here too. I need
> to think about it more.

Actually, I think so. I tested the following sample and got SyntaxError:

class C {
    constructor() {
        this._x = 45;
    }

    get foo() {
        return this._x;
    }
}

class D extends C {

    constructor(x = () => super()) {
        x();
    }

    x() {
        return super.foo; 
    }
}

if ((new D).x() === 45) {
    print("passed");
} else {
    print("failed");
}

The result in v8 and Spider monkey was correct. I set it in the beginning of function and things worked properly.

> > Source/JavaScriptCore/tests/stress/arrow-functions-as-default-parameter-values.js:162
> > +    class D extends C {
> > +        x(y = (y = () => super.foo) => {return y()}) {
> > +            return y();
> > +        }
> > +    }
> 
> Can you also add a test where we use super inside an arrow function inside a
> derived constructor's default parameter expression?

> > LayoutTests/js/script-tests/parser-syntax-check.js:746
> > +valid("class C { constructor() { this._x = 45; } get foo() { return this._x;} } class D extends C { x(y = (y = () => super.foo) => {return y()}) { return y(); } }")
> 
> Ditto for a constructor's syntax here

No problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20160601/4922bc66/attachment.html>


More information about the webkit-unassigned mailing list