www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22965] New: assocArray does not automatically select


          Issue ID: 22965
           Summary: assocArray does not automatically select non-immutable
                    types even if they're easily reachable.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

immutable int a;
auto b = [tuple(a, a)].assocArray;

assocArray should be able to see that while it gets an immutable int as value,
it can trivially convert that to int, which is allowed. Unfortunately, it
instead complains that "assocArray: value type must be mutable", forcing the
awkward `tuple!(int, int)(a, a)`.

Apr 01 2022