[WHLSL] Don't accept operator&& or operator|| in the Lexer
authorrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 21:18:11 +0000 (21:18 +0000)
committerrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 21:18:11 +0000 (21:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200785

Reviewed by Saam Barati.

Source/WebCore:

Implementing && or || as function calls would lose us short-circuiting.

2 new tests in LayoutTests/webgpu/whlsl/lexing.html

* Modules/webgpu/WHLSL/WHLSLLexer.cpp:
(WebCore::WHLSL::Lexer::consumeTokenFromStream):

LayoutTests:

* webgpu/whlsl/lexing.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248746 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl/lexing.html
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/WHLSLLexer.cpp

index 21884eb..97f9adf 100644 (file)
@@ -1,3 +1,12 @@
+2019-08-15  Robin Morisset  <rmorisset@apple.com>
+
+        [WHLSL] Don't accept operator&& or operator|| in the Lexer
+        https://bugs.webkit.org/show_bug.cgi?id=200785
+
+        Reviewed by Saam Barati.
+
+        * webgpu/whlsl/lexing.html:
+
 2019-08-15  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: support `console.screenshot` with detached <canvas>
index 0947af2..6a03f90 100644 (file)
@@ -155,6 +155,18 @@ whlslTests.operatorNames = async () => {
             return 42;
         }
     `);
+
+    await checkFail(`
+        int operator&&(int x, int y) {
+            return 42;
+        }
+    `);
+
+    await checkFail(`
+        bool operator||(int x, int y) {
+            return 42;
+        }
+    `);
 };
 
 runTests(whlslTests);
index e87fdb5..ea9f00d 100644 (file)
@@ -1,3 +1,17 @@
+2019-08-15  Robin Morisset  <rmorisset@apple.com>
+
+        [WHLSL] Don't accept operator&& or operator|| in the Lexer
+        https://bugs.webkit.org/show_bug.cgi?id=200785
+
+        Reviewed by Saam Barati.
+
+        Implementing && or || as function calls would lose us short-circuiting.
+
+        2 new tests in LayoutTests/webgpu/whlsl/lexing.html
+
+        * Modules/webgpu/WHLSL/WHLSLLexer.cpp:
+        (WebCore::WHLSL::Lexer::consumeTokenFromStream):
+
 2019-08-15  Saam Barati  <sbarati@apple.com>
 
         Unreviewed. Debug build fix after r248730.
index f4cca8e..1aa5dfa 100644 (file)
@@ -868,9 +868,6 @@ parseIdentifier:
                 if (consume(']'))
                     return token(Token::Type::OperatorName);
                 return token(Token::Type::Invalid);
-            case '&':
-                shift();
-                return token(Token::Type::OperatorName);
             case '.':
                 shift();
                 if (!isValidIdentifierStart(peek()))
@@ -918,7 +915,6 @@ parseIdentifier:
 
         case '|':
             shift();
-            consume('|');
             return token(Token::Type::OperatorName);
 
         case '=':