Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strict verifyContext invocation from hash_map implementation. #22370

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cdeler
Copy link

@cdeler cdeler commented Dec 31, 2024

Fixes #19640

In this PR I'm trying to remove the strict verifyContext from lib/std/hash_map.zig

How I tested locally

(1) I was able to successfully built the minimal viable test sample from the origin ticket #19640 :

➜  build git:(cdeler_strict_verifyContext_HashTable) ./stage4/bin/zig build-exe cdeler_test/test_minimal.zig
➜  build git:(cdeler_strict_verifyContext_HashTable) echo $?
0

(2) but without the change (upstream zig 0.13.0 from HomeBrew) I still have the error:

➜  build git:(cdeler_strict_verifyContext_HashTable) zig version
0.13.0
➜  build git:(cdeler_strict_verifyContext_HashTable) zig build-exe cdeler_test/test_minimal.zig
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/hash_map.zig:340:13: error: Problems found with hash context type hash_map.StringContext:
                                                                          hash_map.StringContext.hash must be fn (self, []u8) u64
                                                                            but is actually fn (hash_map.StringContext, []const u8) u64
                                                                            Second parameter must be []u8, but is []const u8
                                                                          hash_map.StringContext.eql must be fn (self, []u8, []const u8) bool
                                                                            but is actually fn (hash_map.StringContext, []const u8, []const u8) bool
                                                                            Second parameter must be []u8, but is []const u8
            @compileError("Problems found with hash context type " ++ @typeName(Context) ++ ":" ++ errors);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/hash_map.zig:1174:35: note: called from here
            comptime verifyContext(@TypeOf(ctx), @TypeOf(key), K, Hash, false);
                     ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/hash_map.zig:1337:48: note: called from here
                    const index = self.getIndex(key, key_ctx) orelse return err;
                                  ~~~~~~~~~~~~~^~~~~~~~~~~~~~
referenced by:
    getOrPutAdapted__anon_1630: /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/hash_map.zig:501:57
    main: cdeler_test/test_minimal.zig:11:45
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

(3) std-lib test suite for OS X aarch passed:

➜  build git:(cdeler_strict_verifyContext_HashTable) ✗ ./stage4/bin/zig build test-std -Dskip-release -Dskip-non-native
➜  build git:(cdeler_strict_verifyContext_HashTable) ✗ echo $?
0

@cdeler cdeler force-pushed the cdeler_strict_verifyContext_HashTable branch from 8f5bd88 to ae914ed Compare January 4, 2025 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

verifyContext seems too strict when using adapted HashTable functions
1 participant