Skip to content

Commit dae4186

Browse files
committed
[1.10>master] [MERGE #5569 @aneeshdk] OS:18468078:Adding a check for 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.
2 parents 0377a24 + 51c6097 commit dae4186

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

lib/Parser/Parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12414,7 +12414,7 @@ IdentPtr Parser::ParseSuper(bool fAllowCall)
1241412414
{
1241512415
// Any super access is good within a class constructor
1241612416
}
12417-
else if ((this->m_grfscr & fscrEval) == fscrEval || currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed)
12417+
else if ((this->m_grfscr & fscrEval) == fscrEval || (currentNonLambdaFunc != nullptr && currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed))
1241812418
{
1241912419
// Currently for eval cases during compile time we use propertyallowed and throw during runtime for error cases
1242012420
if (m_token.tk == tkLParen)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SyntaxError: Invalid use of the 'super' keyword
2+
at code (SuperAccessInGlobalLambda.js:6:12)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
() => super.a;

test/Bugs/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,11 @@
530530
<compile-flags>-force:deferparse -parserstatecache -useparserstatecache</compile-flags>
531531
</default>
532532
</test>
533+
<test>
534+
<default>
535+
<files>SuperAccessInGlobalLambda.js</files>
536+
<baseline>SuperAccessInGlobalLambda.baseline</baseline>
537+
<tags>exclude_jshost</tags>
538+
</default>
539+
</test>
533540
</regress-exe>

0 commit comments

Comments
 (0)