[Webkit-unassigned] [Bug 149615] [ES6] Arrow function syntax. Arrow function specific features. Lexical bind "super" property

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 29 16:21:35 PST 2015


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

--- Comment #17 from Saam Barati <sbarati at apple.com> ---
Comment on attachment 267799
  --> https://bugs.webkit.org/attachment.cgi?id=267799
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=267799&action=review

>>> Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp:575
>>> +    if (SourceParseMode::ArrowFunctionMode == parseMode && (functionNode->usesThis() || isDerivedClassContext() || isDerivedConstructorContext()))
>> 
>> Why are these new conditions needed?
>> Why do we need to load this if we're "SourceParseMode::ArrowFunctionMode == parseMode && (isDerivedClassContext() || isDerivedConstructorContext())"?
> 
> Without this condition following code will raise ReferenceError 'this' is undefined so to fix this error I've added this condition.
> 
> var A = class A {
>     constructor() {
>         this.value = 'testValue';
>     }
>     getValue () {
>         return this.value;
>     }
>     
> };
> 
> var B = class B extends A {
>     getParentValue() {
>         var arrow  = () => super.getValue();
>         return arrow();
>     }
> };
> 
> var b = new B();
> b. getParentValue()

Gotcha. Makes sense.

>>> Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp:195
>>> +    EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ);
>> 
>> have you tried this out inside the inspector to make sure it works?
>> I.e, pausing inside an arrow function and typing in "super" into the console?
> 
> Good question. I vent done this. I've checked and it does not work. When I typing 'super' into console it raise exception 'SyntaxError: super is only valid inside functions.' The same behavior inside of the method of class and inside of the arrow function in class method. Looks like bug in class implementation.

It seems like we should just give our parser the ability to allow this behind some flag. super isn't allowed in 'eval', but it's obviously useful to have this ability inside the debugger when paused inside one of these methods/constructors.

-- 
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/20151230/4354deed/attachment.html>


More information about the webkit-unassigned mailing list