-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
std.ComptimeStringMap
gives compile error when giving an empty list
#18212
Comments
what would be the purpose of an empty comptime string map? |
I'm not thoughtful enough to see the expected behavior itself is controversial, but I insist the current behavior extremely confuses users. The expected behavior may be changed to the following: Expected Behavior: If an empty list should be supported, it shall be behave as an empty dict. If it's intentionally disallowed, it should give a clear error message and be reflected in documentation. Personally I think an empty string map should be allowed, for consistency, like Zig already has zero-length tuple and zero-length array. The behavior is intuitive and I haven't see any footgun for it. I agree that deliberately construct an empty comptime map is quite meaningless. But the feature may be useful in metaproramming. |
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes ziglang#18212
Add tests for empty initialization, and some more corner cases (empty key, very long key, duplicate keys). Fixes #18212
Zig Version
0.12.0-dev.1800+559e216f3
Steps to Reproduce and Observed Behavior
When compiling the following code,
it gives the following compile error:
I believe the root cause is that
ComptimeStringMapWithEql
does not handle the special case that the list is empty.Expected Behavior
When providing an empty list,
std.ComptimeStringMap
shall behave as an empty dict, instead of generating compile error.The text was updated successfully, but these errors were encountered: