[Dlang-internal] Const or invariant key in dynamic array

SimonN eiderdaus at gmail.com
Wed Sep 2 06:45:49 UTC 2026


On Monday, 24 August 2026 at 02:55:16 UTC, Valentino Giudice 
wrote:
> What I am suggesting is that if the key is a simple value or a 
> POD, then I should be able to use a constant or immutable key 
> value without getting a warning, as I don't see how it can lead 
> to any issue.

This deprecation warning during @safe was a bug in DMD 2.111 and 
DMD 2.112.

A fix has been available since December 2025:
https://github.com/dlang/dmd/pull/22208

The fix will make it into DMD 2.113.0. Now, the compiler will not 
print a deprecation warning anymore for this compiler-generated 
cast. It's perfectly fine for usercode to index like that in 
@safe code. Keep your code. :-)

With DMD 2.112 or older, you can work around this message by 
hiding all deprecation warnings. Pass `-d` to DMD, or set the 
`DFLAGS` environment variable to `-d` (on Linux: `export 
DFLAGS=-d`) and then build with DMD or dub.

-- Simon


More information about the Dlang-internal mailing list