소스 검색

[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.
Aneesh Divakarakurup 7 년 전
부모
커밋
51c6097dd4
4개의 변경된 파일16개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      lib/Parser/Parse.cpp
  2. 2 0
      test/Bugs/SuperAccessInGlobalLambda.baseline
  3. 6 0
      test/Bugs/SuperAccessInGlobalLambda.js
  4. 7 0
      test/Bugs/rlexe.xml

+ 1 - 1
lib/Parser/Parse.cpp

@@ -12323,7 +12323,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)

+ 2 - 0
test/Bugs/SuperAccessInGlobalLambda.baseline

@@ -0,0 +1,2 @@
+SyntaxError: Invalid use of the 'super' keyword
+	at code (SuperAccessInGlobalLambda.js:6:12)

+ 6 - 0
test/Bugs/SuperAccessInGlobalLambda.js

@@ -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 - 0
test/Bugs/rlexe.xml

@@ -523,4 +523,11 @@
       <compile-flags>-force:cachedScope</compile-flags>
     </default>
   </test>
+  <test>
+    <default>
+      <files>SuperAccessInGlobalLambda.js</files>
+      <baseline>SuperAccessInGlobalLambda.baseline</baseline>
+      <tags>exclude_jshost</tags>
+    </default>
+  </test>
 </regress-exe>