-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Update dict hashability check, once the language spec is updated #8730
Comments
When the flag is enabled, dict lookup of unhashable keys will fail. For example using the `in` operator or `dict.get` with unhashabled types. RELNOTES: Flag `--incompatible_disallow_dict_lookup_unhashable_keys` is added. See bazelbuild#8730
Related: bazelbuild/starlark#65, #8730 Closes #8837. PiperOrigin-RevId: 257578468
bazelbuild#8730 Closes bazelbuild#8762. PiperOrigin-RevId: 256987262
Related: bazelbuild/starlark#65, bazelbuild#8730 Closes bazelbuild#8837. PiperOrigin-RevId: 257578468
The spec wording actually seems to indicate that
Since That said, it's clearly undecided as per bazelbuild/starlark#65. Leaving this issue open to track it from Bazel's side. |
Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so. |
According to the spec,
The meaning of membership varies by the type of the second operand: the members of a list or tuple are its elements; the members of a dict are its keys; the members of a string are all its substrings.
.This implies that to use the
in
operator with dict as a right operand, the left operand has to be a hashable type (like what python does, giving an error if it's not hashable). Also, it'd make no meaning to search for a key that cannot be hashed. Thus the following should give an error rather thanFalse
:The text was updated successfully, but these errors were encountered: