Ignore:
Timestamp:
Oct 11, 2017, 5:59:36 AM (8 years ago)
Author:
Caio Lima
Message:

Object properties are undefined in super.call() but not in this.call()
https://bugs.webkit.org/show_bug.cgi?id=177230

Reviewed by Saam Barati.

JSTests:

  • stress/super-call-function-subclass.js: Added.

(assert):
(A.prototype.t):
(A):

  • stress/super-dot-call-and-apply.js: Added.

(assert):
(A):
(A.prototype.call):
(A.prototype.apply):
(B.prototype.testSuper):
(B):
(const.obj.new.B.string_appeared_here.obj.testSuper.C):
(D.prototype.testSuper):
(D):

Source/JavaScriptCore:

Bytecode generation for "super.call(...)" or "super.apply(...)"
shouldn't be considered as CallFunctionCallDotNode or
ApplyFunctionCallDotNode because they should be considered as common
super property access as any other function. According to spec[1],
"super" is not refering to parent constructor.

[1] - https://tc39.github.io/ecma262/#sec-super-keyword-runtime-semantics-evaluation

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::makeFunctionCallNode):

  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::makeFunctionCallNode):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r223124 r223175  
    46484648
    46494649    bool baseIsSuper = match(SUPER);
     4650    bool previousBaseWasSuper = false;
    46504651    bool baseIsImport = match(IMPORT);
    46514652    semanticFailIfTrue((baseIsSuper || baseIsImport) && newCount, "Cannot use new with ", getToken());
     
    47894790                        functionScope->setInnerArrowFunctionUsesSuperCall();
    47904791                }
    4791                 base = context.makeFunctionCallNode(startLocation, base, arguments, expressionStart,
     4792                base = context.makeFunctionCallNode(startLocation, base, previousBaseWasSuper, arguments, expressionStart,
    47924793                    expressionEnd, lastTokenEndPosition(), callOrApplyDepthScope ? callOrApplyDepthScope->distanceToInnermostChild() : 0);
    47934794            }
     
    48194820            goto endMemberExpression;
    48204821        }
     4822        previousBaseWasSuper = baseIsSuper;
    48214823        baseIsSuper = false;
    48224824    }
Note: See TracChangeset for help on using the changeset viewer.