[Issue 20938] New: Cannot create const arrays mixing immutable and mutable structs with indirections
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 16 16:43:34 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20938
Issue ID: 20938
Summary: Cannot create const arrays mixing immutable and
mutable structs with indirections
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: pro.mathias.lang at gmail.com
```
struct Block { int[] ind; }
private immutable Block _gen;
ref immutable(Block) Genesis() { return _gen; }
void main ()
{
Block block;
// conv.d(10): Error: cannot implicitly convert expression Genesis() of
type immutable(Block) to Block
auto a1 = [ Genesis(), block ];
// conv.d(12): Error: cannot implicitly convert expression Genesis() of
type immutable(Block) to Block
const a2 = [ Genesis(), block ];
// conv.d(14): Error: cannot implicitly convert expression Genesis() of
type immutable(Block) to Block
const(Block)[] a3 = [ Genesis(), block ];
// conv.d(16): Error: cannot implicitly convert expression Genesis() of
type immutable(Block) to Block
const(Block)[2] a4 = [ Genesis(), block ];
// conv.d(18): Error: cannot implicitly convert expression block of type
Block to immutable(Block)
const(Block)[] a5 = [ block, Genesis() ];
}
```
Marking as critical because inference not working is one thing, but the error
on `const(Block)[]` is a rejects-valid and the error message is quite
confusing.
--
More information about the Digitalmars-d-bugs
mailing list