fixed type mismatches in SkSL comparison operators

Bug: skia:
Change-Id: I8f05088c561a80549264f7a65cb8161bbe7d8f4c
Reviewed-on: https://skia-review.googlesource.com/116982
Reviewed-by: Chris Dalton <csmartdalton@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp
index 815ec15..56d8e5e 100644
--- a/src/sksl/SkSLIRGenerator.cpp
+++ b/src/sksl/SkSLIRGenerator.cpp
@@ -1092,15 +1092,18 @@
             return right.canCoerceTo(left);
         case Token::EQEQ: // fall through
         case Token::NEQ:
-            if (left == right) {
+            if (right.canCoerceTo(left)) {
                 *outLeftType = &left;
+                *outRightType = &left;
+                *outResultType = context.fBool_Type.get();
+                return true;
+            } if (left.canCoerceTo(right)) {
+                *outLeftType = &right;
                 *outRightType = &right;
                 *outResultType = context.fBool_Type.get();
                 return true;
             }
-            isLogical = true;
-            validMatrixOrVectorOp = true;
-            break;
+            return false;
         case Token::LT:   // fall through
         case Token::GT:   // fall through
         case Token::LTEQ: // fall through
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index 9c43ac5..c24a25d 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -245,6 +245,12 @@
     test_failure(r,
                  "void main() { bool x = 1 || 2.0; }",
                  "error: 1: type mismatch: '||' cannot operate on 'int', 'float'\n1 error\n");
+    test_failure(r,
+                 "void main() { bool x = float2(0) == 0; }",
+                 "error: 1: type mismatch: '==' cannot operate on 'float2', 'int'\n1 error\n");
+    test_failure(r,
+                 "void main() { bool x = float2(0) != 0; }",
+                 "error: 1: type mismatch: '!=' cannot operate on 'float2', 'int'\n1 error\n");
 }
 
 DEF_TEST(SkSLCallNonFunction, r) {