Ignore:
Timestamp:
Nov 20, 2015, 1:19:57 PM (10 years ago)
Author:
Yusuke Suzuki
Message:

Super use should be recorded in per-function scope
https://bugs.webkit.org/show_bug.cgi?id=151500

Reviewed by Geoffrey Garen.

"super" use is prohibited under the non-constructor / non-class-method-related functions.
This "super" use should be recorded in per-function scope to check its incorrect use after
parsing a function.
Currently, we accidentally record it to a lexical current scope. So when using "super" inside
a block scope, our "super" use guard miss it.

  • parser/Parser.cpp:

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

  • parser/Parser.h:

(JSC::Parser::currentVariableScope):
(JSC::Parser::currentFunctionScope):
(JSC::Parser::declareVariable):

  • tests/stress/super-in-lexical-scope.js: Added.

(testSyntax):
(testSyntaxError):
(testSyntaxError.test):

File:
1 edited

Legend:

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

    r192671 r192695  
    35563556        base = context.createSuperExpr(location);
    35573557        next();
    3558         currentScope()->setNeedsSuperBinding();
     3558        currentFunctionScope()->setNeedsSuperBinding();
    35593559    } else if (!baseIsNewTarget)
    35603560        base = parsePrimaryExpression(context);
     
    35913591                failIfFalse(arguments, "Cannot parse call arguments");
    35923592                if (baseIsSuper)
    3593                     currentScope()->setHasDirectSuper();
     3593                    currentFunctionScope()->setHasDirectSuper();
    35943594                base = context.makeFunctionCallNode(startLocation, base, arguments, expressionStart, expressionEnd, lastTokenEndPosition());
    35953595            }
Note: See TracChangeset for help on using the changeset viewer.