tint/resolver: Fix const-eval Equal()

It was not considering structures, and the default clause was happily assuming two std::monostates (no-value) were equal.
This lead to non-deterministic behaviour as the Hash() would sometimes match and sometimes not.

Change-Id: Idf01a9e0e4ac09d5eaf683b62fcadd1714dc5849
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113981
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/resolver/const_eval.cc b/src/tint/resolver/const_eval.cc
index 1881f03..1587ee1 100644
--- a/src/tint/resolver/const_eval.cc
+++ b/src/tint/resolver/const_eval.cc
@@ -560,7 +560,22 @@
 
             return false;
         },
-        [&](Default) { return a->Value() == b->Value(); });
+        [&](const type::Struct* str) {
+            auto count = str->Members().Length();
+            for (size_t i = 0; i < count; i++) {
+                if (!Equal(a->Index(i), b->Index(i))) {
+                    return false;
+                }
+            }
+            return true;
+        },
+        [&](Default) {
+            auto va = a->Value();
+            auto vb = b->Value();
+            TINT_ASSERT(Resolver, !std::holds_alternative<std::monostate>(va));
+            TINT_ASSERT(Resolver, !std::holds_alternative<std::monostate>(vb));
+            return va == vb;
+        });
 }
 
 /// CreateComposite is used to construct a constant of a vector, matrix or array type.