www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21296] New: std.variant.Variant cannot be initialized with

https://issues.dlang.org/show_bug.cgi?id=21296

          Issue ID: 21296
           Summary: std.variant.Variant cannot be initialized with
                    immutable AA
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ttanjo gmail.com

I confirmed this issue with dmd 2.094.0 on my WSL environment and with
run.dlang.io (https://run.dlang.io/is/EI2fhc).

- How to reproduce:
```
$ cat sample.d
import std.variant;

void main()
{
    immutable aa = ["0":0];
    auto v = Variant(aa);
}
$ dmd sample.d
```

- Expected behavior: The dmd command successfully compiles the source code and
generates an executable file.
- Actual behavior: It fails compiling with the following messages:
```
$ dmd sample.d
/home/ttanjo/dlang/dmd-2.094.0/linux/bin64/../../src/phobos/std/variant.d(490):
Error: cannot modify immutable expression (*zis)[args[1].get()]
/home/ttanjo/dlang/dmd-2.094.0/linux/bin64/../../src/phobos/std/variant.d(707):
Error: template instance
std.variant.VariantN!32LU.VariantN.handler!(immutable(int[string])) error
instantiating
/home/ttanjo/dlang/dmd-2.094.0/linux/bin64/../../src/phobos/std/variant.d(604):
       instantiated from here: opAssign!(immutable(int[string]))
sample.d(6):        instantiated from here: __ctor!(immutable(int[string]))
```

I guess this issue is the source of the problem of Issue 13930.

--
Oct 07 2020