Title: [221497] trunk/Tools
Revision
221497
Author
fpi...@apple.com
Date
2017-09-01 14:45:30 -0700 (Fri, 01 Sep 2017)

Log Message

WSL should have more tests of type checking failures
https://bugs.webkit.org/show_bug.cgi?id=176244

Reviewed by Myles Maxfield.

* WebGPUShadingLanguageRI/Checker.js:
(Checker.prototype.visitProtocolDecl.set throw):
* WebGPUShadingLanguageRI/Test.js:
(TEST_typeMismatchReturn):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (221496 => 221497)


--- trunk/Tools/ChangeLog	2017-09-01 21:35:30 UTC (rev 221496)
+++ trunk/Tools/ChangeLog	2017-09-01 21:45:30 UTC (rev 221497)
@@ -1,5 +1,17 @@
 2017-09-01  Filip Pizlo  <fpi...@apple.com>
 
+        WSL should have more tests of type checking failures
+        https://bugs.webkit.org/show_bug.cgi?id=176244
+
+        Reviewed by Myles Maxfield.
+
+        * WebGPUShadingLanguageRI/Checker.js:
+        (Checker.prototype.visitProtocolDecl.set throw):
+        * WebGPUShadingLanguageRI/Test.js:
+        (TEST_typeMismatchReturn):
+
+2017-09-01  Filip Pizlo  <fpi...@apple.com>
+
         WSL should be be able to call a function declared in a protocol from a generic function
         https://bugs.webkit.org/show_bug.cgi?id=176242
 

Modified: trunk/Tools/WebGPUShadingLanguageRI/Checker.js (221496 => 221497)


--- trunk/Tools/WebGPUShadingLanguageRI/Checker.js	2017-09-01 21:35:30 UTC (rev 221496)
+++ trunk/Tools/WebGPUShadingLanguageRI/Checker.js	2017-09-01 21:45:30 UTC (rev 221497)
@@ -165,11 +165,11 @@
             if (!resultType)
                 throw new Error("Null result type from " + node.value);
             if (!node.func.returnType.equals(resultType))
-                throw new WTypeError(node.origin.originString, "Trying to return " + resultType + " in a function that returns " + func.returnType);
+                throw new WTypeError(node.origin.originString, "Trying to return " + resultType + " in a function that returns " + node.func.returnType);
             return;
         }
         
-        if (!func.returnType.equals(this._program.intrinsics.void))
+        if (!node.func.returnType.equals(this._program.intrinsics.void))
             throw new WTypeError(node.origin.originString, "Non-void function must return a value");
     }
     

Modified: trunk/Tools/WebGPUShadingLanguageRI/Test.js (221496 => 221497)


--- trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-09-01 21:35:30 UTC (rev 221496)
+++ trunk/Tools/WebGPUShadingLanguageRI/Test.js	2017-09-01 21:45:30 UTC (rev 221497)
@@ -252,6 +252,68 @@
     checkInt(program, callFunction(program, "foo", [], [makeInt(program, 45)]), 45 + 73);
 }
 
+function TEST_typeMismatchReturn()
+{
+    checkFail(
+        () => doPrep(`
+            int foo()
+            {
+                return 0u;
+            }
+        `),
+        (e) => e instanceof WTypeError);
+}
+
+function TEST_typeMismatchVariableDecl()
+{
+    checkFail(
+        () => doPrep(`
+            void foo(uint x)
+            {
+                int y = x;
+            }
+        `),
+        (e) => e instanceof WTypeError);
+}
+
+function TEST_typeMismatchAssignment()
+{
+    checkFail(
+        () => doPrep(`
+            void foo(uint x)
+            {
+                int y;
+                y = x;
+            }
+        `),
+        (e) => e instanceof WTypeError);
+}
+
+function TEST_typeMismatchReturnParam()
+{
+    checkFail(
+        () => doPrep(`
+            int foo(uint x)
+            {
+                return x;
+            }
+        `),
+        (e) => e instanceof WTypeError);
+}
+
+function TEST_badAdd()
+{
+    checkFail(
+        () => doPrep(`
+            void bar<T>(T) { }
+            void foo(int x, uint y)
+            {
+                bar(x + y);
+            }
+        `),
+        (e) => e instanceof WTypeError && e.message.indexOf("native int32 operator+<>(int32,int32)") != -1);
+}
+
 let before = preciseTime();
 
 let filter = /.*/; // run everything by default
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to