[Issue 21296] New: std.variant.Variant cannot be initialized with immutable AA
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 7 09:34:43 UTC 2020
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 at puremagic.com
Reporter: ttanjo at 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.
--
More information about the Digitalmars-d-bugs
mailing list