From ef0f3ba905e992556a60f935cbb7cb30cf1f27db Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 18 Sep 2019 16:34:36 -0400 Subject: relax std.auto_hash requirements regarding vectors Previously, auto hash tests required vectors of different types to not hash to the same value. Now, this is allowed. --- std/hash/auto_hash.zig | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'std/hash') diff --git a/std/hash/auto_hash.zig b/std/hash/auto_hash.zig index d34fc2719a..8a22788e5c 100644 --- a/std/hash/auto_hash.zig +++ b/std/hash/auto_hash.zig @@ -116,7 +116,7 @@ pub fn hash(hasher: var, key: var, comptime strat: HashStrategy) void { // Otherwise, hash every element. // TODO remove the copy to an array once field access is done. const array: [info.len]info.child = key; - comptime var i: u32 = 0; + comptime var i = 0; inline while (i < info.len) : (i += 1) { hash(hasher, array[i], strat); } @@ -357,10 +357,13 @@ test "testHash union" { test "testHash vector" { const a: @Vector(4, u32) = [_]u32{ 1, 2, 3, 4 }; const b: @Vector(4, u32) = [_]u32{ 1, 2, 3, 5 }; - const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 }; testing.expect(testHash(a) == testHash(a)); testing.expect(testHash(a) != testHash(b)); - testing.expect(testHash(a) != testHash(c)); + + const c: @Vector(4, u31) = [_]u31{ 1, 2, 3, 4 }; + const d: @Vector(4, u31) = [_]u31{ 1, 2, 3, 5 }; + testing.expect(testHash(c) == testHash(c)); + testing.expect(testHash(c) != testHash(d)); } test "testHash error union" { -- cgit v1.2.3