Skip to content

Commit

Permalink
[1.10>master] [MERGE #5569 @aneeshdk] OS:18468078:Adding a check for …
Browse files Browse the repository at this point in the history
…the case where lambda method accessing super in global scope

Merge pull request #5569 from aneeshdk:SuperGlobalAccessIssue

When a labmda method access super property in the global scope the currentnonlambdafunc will be nullptr. This should be a SyntaxError.
  • Loading branch information
aneeshdk committed Aug 3, 2018
2 parents 0377a24 + 51c6097 commit dae4186
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Parser/Parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12414,7 +12414,7 @@ IdentPtr Parser::ParseSuper(bool fAllowCall)
{
// Any super access is good within a class constructor
}
else if ((this->m_grfscr & fscrEval) == fscrEval || currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed)
else if ((this->m_grfscr & fscrEval) == fscrEval || (currentNonLambdaFunc != nullptr && currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed))
{
// Currently for eval cases during compile time we use propertyallowed and throw during runtime for error cases
if (m_token.tk == tkLParen)
Expand Down
2 changes: 2 additions & 0 deletions test/Bugs/SuperAccessInGlobalLambda.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SyntaxError: Invalid use of the 'super' keyword
at code (SuperAccessInGlobalLambda.js:6:12)
6 changes: 6 additions & 0 deletions test/Bugs/SuperAccessInGlobalLambda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

() => super.a;
7 changes: 7 additions & 0 deletions test/Bugs/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -530,4 +530,11 @@
<compile-flags>-force:deferparse -parserstatecache -useparserstatecache</compile-flags>
</default>
</test>
<test>
<default>
<files>SuperAccessInGlobalLambda.js</files>
<baseline>SuperAccessInGlobalLambda.baseline</baseline>
<tags>exclude_jshost</tags>
</default>
</test>
</regress-exe>

0 comments on commit dae4186

Please sign in to comment.