Skip to content

Commit 5d1a0ee

Browse files
committed
OS:18468078:Adding a check for the case where lambda method accessing super in global scope
When a labmda method access super property in the global scope the currentnonlambdafunc will be nullptr. This should be a SyntaxError.
1 parent 47df46c commit 5d1a0ee

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
@@ -12323,7 +12323,7 @@ IdentPtr Parser::ParseSuper(bool fAllowCall)
1232312323
{
1232412324
// Any super access is good within a class constructor
1232512325
}
12326-
else if ((this->m_grfscr & fscrEval) == fscrEval || currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed)
12326+
else if ((this->m_grfscr & fscrEval) == fscrEval || (currentNonLambdaFunc != nullptr && currentNonLambdaFunc->superRestrictionState == SuperRestrictionState::PropertyAllowed))
1232712327
{
1232812328
// Currently for eval cases during compile time we use propertyallowed and throw during runtime for error cases
1232912329
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
@@ -523,4 +523,11 @@
523523
<compile-flags>-force:cachedScope</compile-flags>
524524
</default>
525525
</test>
526+
<test>
527+
<default>
528+
<files>SuperAccessInGlobalLambda.js</files>
529+
<baseline>SuperAccessInGlobalLambda.baseline</baseline>
530+
<tags>exclude_jshost</tags>
531+
</default>
532+
</test>
526533
</regress-exe>

0 commit comments

Comments
 (0)