[Issue 2954] [tdpl] Allow to set associative array key value only using expression AA key type is constructable from
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Mar 27 16:25:08 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=2954
Steven Schveighoffer <schveiguy at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |schveiguy at gmail.com
--- Comment #15 from Steven Schveighoffer <schveiguy at gmail.com> ---
This oddity just came up with a related bug in std.net.curl (to be fixed
shortly). I can't believe this is still a problem, almost 15 years later!
For my 2 cents:
1. aa[idx] = value; should only accept idx that is implicitly convertible to
the key type.
2. Other operations such as `idx in aa` or `aa[idx]` (which are not setting
values/keys) should be fine as long as the key type can convert to the idx.
We also lack some sort of mechanism to say "look up using this key, and if not
present, use this *conversion routine* to convert the key before assigning the
new value". `aa.update` only allows different paths for the value.
But maybe this is such a niche problem that it's not worth adding a mechanism.
--
More information about the Digitalmars-d-bugs
mailing list