Bug 20938 – Cannot create const arrays mixing immutable and mutable structs with indirections
Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-16T16:43:34Z
Last change time
2020-06-21T14:00:47Z
Keywords
pull, rejects-valid
Assigned to
No Owner
Creator
Mathias LANG
Comments
Comment #0 by pro.mathias.lang — 2020-06-16T16:43:34Z
```
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.
Comment #1 by dlang-bot — 2020-06-17T12:18:55Z
@Biotronic created dlang/dmd pull request #11292 "Fix issue 20938 - Cannot create const arrays mixing immutable and mutable structs with indirections" fixing this issue:
- Fix issue 20938
https://github.com/dlang/dmd/pull/11292
Comment #2 by dlang-bot — 2020-06-21T14:00:47Z
dlang/dmd pull request #11292 "Fix issue 20938 - Cannot create const arrays mixing immutable and mutable structs with indirections" was merged into master:
- 6697c5bab0bda54ccaf8e3060b098be23b98931f by Simen Kjærås:
Fix issue 20938 - Cannot create const arrays mixing immutable and
mutable structs with indirections
https://github.com/dlang/dmd/pull/11292