Change Log: 2.111.0
Download D nightlies
To be released
This changelog has been automatically generated from all commits in master since the last release.
- The full-text messages are assembled from the changelog/ directories of the respective repositories: dmd, druntime, phobos, tools, dlang.org, installer, and dub.
- See the DLang-Bot documentation for details on referencing Bugzilla. The DAutoTest PR preview doesn't include the Bugzilla changelog.
- The pending changelog can be generated locally by setting up dlang.org and running the pending_changelog target:
make -f posix.mak pending_changelog
Compiler changes
- Keywords auto and ref must be adjacent
- Copying from const(void)[] to void[] is disallowed with -preview=fixImmutableConv
- An error is now given for case fallthough for multivalued cases
- An error is now given for constructors with field destructors with stricter attributes
- An error is now issued for in/out contracts of nothrow functions that may throw
- Build time profiling has been added to dmd
- Using the compiler flag -i will now properly pick up C source files
- Import expressions are now treated as hex strings
- A pragma for ImportC allows to set nothrow, @nogc or pure
- Mixin templates can now use assignment syntax
- Add -oq switch to DMD
- Postfix type qualifier method attributes for -H and -D
- ref and auto ref can now be applied to local, static, extern, and global variables
- bool values other than 0 or 1 are not @safe
Library changes
List of all upcoming bug fixes and enhancements in D 2.111.0.
Compiler changes
- Keywords auto and ref must be adjacent
It's now deprecated to declare auto ref parameters without putting those two keywords next to each other. This way it's clear that auto ref semantics are intended, rather than ref and auto semantics separately. For the newly introduced ref local / global variables, it's an error immediately.
void t()(ref const auto int x) // Deprecation { ref auto y = x; // Error } // Correction: void t()(auto ref const int x) { auto ref y = x; }
- Copying from const(void)[] to void[] is disallowed with -preview=fixImmutableConv
If const(void)[] data contains tail const pointers, copying to void[] can subsequently violate const data:
void f(int*[] a, const int*[] b) { void[] va = a; const void[] vb = b; va[] = vb[]; // fills `a` with pointers to const *a[0] = 0; // const data mutated }
Copying vb data to va is no longer allowed with the -preview=fixImmutableConv switch.
- An error is now given for case fallthough for multivalued cases
This used to give a deprecation, this now gives an error:
int i; switch (0) { case 0, 1: i = 20; default: assert(0); // Error: switch case fallthrough - use 'goto default;' if intended } switch (0) { default: case 0, 1: i = 20; case 2, 3: i = 30; // Error: switch case fallthrough - use 'goto case;' if intended }
- An error is now given for constructors with field destructors with stricter attributes
struct HasDtor { ~this() {} } struct Pure { HasDtor member; this(int) pure {} // Error: `this` has stricter attributes than its destructor (`pure`) } struct Nothrow { HasDtor member; this(int) nothrow {} // Error: `this` has stricter attributes than its destructor (`nothrow`) } struct NoGC { HasDtor member; this(int) @nogc {} // Error: `this` has stricter attributes than its destructor (`@nogc`) } struct Safe { HasDtor member; this(int) @safe {} // Error: `this` has stricter attributes than its destructor (`@safe`) }
- An error is now issued for in/out contracts of nothrow functions that may throw
This used to issue a deprecation, it is now an error:
void test() nothrow in { throw new Exception(null); // Error: `in` contract may throw but function is marked as `nothrow` } out { throw new Exception(null); // Error: `out` contract may throw but function is marked as `nothrow` } do { }
- Build time profiling has been added to dmd
The -ftime-trace switch that the LDC compiler already has, is now also available in dmd. It can be used to figure out which parts of your code take the longest to compile, so you can optimize your build times.
dmd -ftime-trace app.d
This will output app.o.time-trace.
A different output file can be selected with -ftime-trace-file=trace.json.
The output is in Google Chrome's profiler format, which can be viewed in an interactive viewer like ui.perfetto.dev.
See also this YouTube tutorial: Easily Reduce Build Times by Profiling the D Compiler
- Using the compiler flag -i will now properly pick up C source files
Previously you needed to manually include .c source files, it now works just like with .d files
- Import expressions are now treated as hex strings
While Import expressions are typed as string, they are also used to embed binary files. By treating them the same as hex strings, they will implicitly convert to arrays of integral types other than char.
// Formerly, a cast was required: immutable ubyte[] iconImg = cast(immutable ubyte[]) import("icon.png"); // Now, it implicitly converts to integral arrays: immutable ubyte[] iconImg = import("icon.png");
- A pragma for ImportC allows to set nothrow, @nogc or pure
The following new pragma for ImportC allows to set default storage classes for function declarations:
#pragma attribute(push, [storage classes...])
The storage classes nothrow, nogc and pure are supported. Unrecognized attributes are ignored. Enabling a default storage class affects all function declarations after the pragma until it is disabled with another pragma. Declarations in includes are also affected. The following example enables @nogc and nothrow for a library:
#pragma attribute(push, nogc, nothrow) #include <somelibrary.h>
The changed storage classes are pushed on a stack. The last change can be undone with the following pragma:
#pragma attribute(pop)
This can also disable multiple default storage classes at the same time, if they were enabled with a single #pragma attribute(push, ...) directive.
- Mixin templates can now use assignment syntax
Previously, giving a name to a mixed-in mixin template instance required putting the name at the end. Now, it can also go in front of the instantiation using assignment syntax.
mixin MyMixinTemplate!(Args) myName; // old style mixin myName = MyMixinTemplate!(Args); // new style
- Add -oq switch to DMD
The switch gives fully qualified names to object files, preventing name conflicts when using the -od switch while compiling multiple modules with the same name, but inside different packages. The switch already existed in LDC, but is now in dmd as well.
Example:
dmd -c -oq -od=. app.d util/app.d misc/app.d
This will output app.obj, util.app.obj, and misc.app.obj, instead of just app.obj.
-oq also applies to other outputs, such as DDoc (-D -Dd=.) and .di header generation (-H -Hd=.).
- Postfix type qualifier method attributes for -H and -D
.di interface file generation and Ddoc output will now have type qualifier attributes placed after the parameter list for methods (and constructors). This avoids confusion with the return type.
struct S { const int f(); // before int f() const; // now }
- ref and auto ref can now be applied to local, static, extern, and global variables
For example, one can now write:
struct S { int a; } void main() { S s; ref int r = s.a; r = 3; assert(s.a == 3); auto ref x = 0; auto ref y = x; static assert(!__traits(isRef, x)); static assert( __traits(isRef, y)); }
- bool values other than 0 or 1 are not @safe
The spec was updated (for 2.109) so that only 0 and 1 are safe values for bool. This means that reading a bool value whose underlying byte representation has other bits set is implementation-defined and should be avoided. Consequently the following are deprecated in @safe code:
- void initialization of booleans (since 2.109)
- Reading a bool field from a union (since 2.109)
- Runtime casting a dynamic array to a bool dynamic array type
- Runtime casting a bool dynamic array to a tail mutable dynamic array type
- Casting a pointer to a bool pointer type
- Casting a bool pointer to a tail mutable pointer type
Runtime changes
- Remove criticalRegionLock
The criticalRegionLock feature suffer from a serious design flaw: https://issues.dlang.org/show_bug.cgi?id=24741
It turns out it is not used, so rather than fixing the flaw, the feature was removed.
- Adds expect, [un]likely, trap to core.builtins
Adds the functions expect and likely/unlikely` for branch and value hints for the LDC/GDC compilers. DMD ignores these hints.
Adds trap to lowered to the target dependent trap instruction. If the target does not have a trap instruction, this intrinsic will be lowered to the call of the abort() function.
Library changes
- Added popGrapheme function to std.uni.
The new function is a cross between the existing std.uni.graphemeStride and std.uni.decodeGrapheme functions. The new function both supports @safe pure nothrow @nogc like graphemeStride does as long as you don't rely on autodecoding (side node: @nogc support for graphemeStride added in this release), and works with any non-array ranges just like decodeGrapheme does.
Example:
import std.uni; // Two Union Jacks of the Great Britain in each string s = "\U0001F1EC\U0001F1E7\U0001F1EC\U0001F1E7"; wstring ws = "\U0001F1EC\U0001F1E7\U0001F1EC\U0001F1E7"; dstring ds = "\U0001F1EC\U0001F1E7\U0001F1EC\U0001F1E7"; // String pop length in code units, not points. assert(s.popGrapheme() == 8); assert(ws.popGrapheme() == 4); assert(ds.popGrapheme() == 2); assert(s == "\U0001F1EC\U0001F1E7"); assert(ws == "\U0001F1EC\U0001F1E7"); assert(ds == "\U0001F1EC\U0001F1E7"); import std.algorithm.comparison : equal; import std.algorithm.iteration : filter; // Also works for non-random access ranges as long as the // character type is 32-bit. auto testPiece = "\r\nhello!"d.filter!(x => !x.isAlpha); // Windows-style line ending is two code point in a single grapheme. assert(testPiece.popGrapheme() == 2); assert(testPiece.equal("!"d));
Dub changes
- dub.selections.json files are now looked up in parent directories too
In case the root package directory doesn't contain a dub.selections.json file, dub now looks in parent directories too and potentially uses the first (deepest) one it finds - if and only if that JSON file contains an optional new "inheritable": true flag.
This allows using a 'central' dub.selections.json file for a repository containing multiple dub projects, making it automatically apply to all builds in that source tree if located in the repository root directory (unless a local dub.selections.json overrides it).
Such an inherited selections file is never mutated when running dub for a nested project, i.e., changes are always saved to a local dub.selections.json file. E.g., when running dub upgrade for a nested project.
List of all bug fixes and enhancements in D 2.111.0:
DMD Compiler bug fixes
- Bugzilla 12885: const union wrongly converts implicitly to mutable
- Bugzilla 16643: CTFE internal error with null
- Bugzilla 17148: Copying from const(void)[] to void[] breaks immutable
- Bugzilla 21995: Struct with size uint.max or greater causes ICE
- Bugzilla 23294: [dip1000] parameter to parameter assignment leads to incorrect scope inference
- Bugzilla 23830: Azure failure for OMF: Module name not printed before struct symbol
- Bugzilla 23841: isZeroInit does not take into account unions
- Bugzilla 23957: Casting to derived extern(C++) class is unsafe
- Bugzilla 24375: ImportC: .di generator outputs C expression with -> operator
- Bugzilla 24447: ImportC: extern symbols cannot have initializers
- Bugzilla 24534: Having a label on a declaration makes it possible to skip it with goto
- Bugzilla 24558: C asserts segfault on Glibc
- Bugzilla 24577: Struct with constructor returned from C++ wrong
- Bugzilla 24582: Detect unsafe cast(bool[])
- Bugzilla 24583: di generator emits return scope and scope return in wrong order
- Bugzilla 24592: ImportC: Bitfield layout wrong for int64 on 32-bit Linux
- Bugzilla 24594: ImportC: Packed struct has wrong layout
- Bugzilla 24603: Can copy from non-void array into void[] in safe code
- Bugzilla 24622: Modify const data with void[] concatenation/append
- Bugzilla 24630: Casting a bool pointer to a mutable pointer type is unsafe
- Bugzilla 24631: Pointer cast allows changing @system field in @safe code
- Bugzilla 24634: Parse error initializing array from expression with StructInitializer
- Bugzilla 24651: Bitfield layout wrong for 48-bit field on 32-bit Linux
- Bugzilla 24663: dip1000 doesn't check slice expression implicitly converted to static array
- Bugzilla 24669: ImportC: C files are not compiled with '-i' flag
- Bugzilla 24670: importC: .di generation does not place parentheses around const struct return types
- Bugzilla 24694: [DIP1000] can escape stack pointer through struct.class.field
- Bugzilla 24701: No error produced from casted noreturn variable
- Bugzilla 24705: Arguments of synchronized method are unintentionally treated as shared with -preview=nosharedaccess
- Bugzilla 24706: Missing errors for first operand of comma expression
- Bugzilla 24707: error message has bad parameter attribute order
- Bugzilla 24733: ImportC: #pragma pack(pop) restores wrong alignment
- Bugzilla 24748: DMD can't output object files with fully qualified name, making -od overwirte each other file
- Bugzilla 24762: @nogc false positive error
- Bugzilla 24776: Struct with anonymous union has wrong isZeroInit
- Bugzilla 24803: __traits(location) is inconsistent with modules
DMD Compiler enhancements
- Bugzilla 9997: Missed misspell suggestions for UFCS
- Bugzilla 20243: inout not substituted for in associative array key type
- Bugzilla 21564: Allow assignment syntax for instantiating mixin templates
- Bugzilla 23449: spellchecker should suggest corrections for pointer members
- Bugzilla 23812: ImportC: allow adding function attributes to imported C functions
- Bugzilla 24135: Eponymous template member overloads not shown as call candidates
- Bugzilla 24580: ImportC: Asm label after attributes results in syntax error
- Bugzilla 24598: OpenBSD: adapt compiler tests
- Bugzilla 24623: Rename version CppRuntime_Clang/Gcc to CppRuntime_libcxx/libstdcxx.
- Bugzilla 24639: ImportC: defines of negative constants not detected for enum conversion
- Bugzilla 24645: Hidden static assert error messages if more than 20 errors
- Bugzilla 24738: Import core.interpolation suggestion
- Bugzilla 24749: A clause consisting only of "throw" should be the unlikely path
Phobos bug fixes
- Bugzilla 14138: std.parallelism.task breaks @safety
- Bugzilla 15315: can break immutable with std.algorithm.move
- Bugzilla 20870: std.outbuffer.printf is trusted
- Bugzilla 20872: std.array.assocArray trusts user-provided 'front' for values
- Bugzilla 23300: std.array : array wrongly propagates scopeness of source
- Bugzilla 24564: std.file.DirEntry throws Exception instead of FileException
- Bugzilla 24667: goo.gl is going away
- Bugzilla 24685: std.stdio.File.rawRead allows reading raw pointers from files in @safe code
- Bugzilla 24704: The error message for DateTime.fromISOExtString says that valid ISO extended strings that it does not support are invalid ISO extended strings
- Bugzilla 24715: std/process: Default to libc closefrom in spawnProcessPosix
- Bugzilla 24773: Stable sort() invokes the destructor on uninitialized elements
Phobos enhancements
- Bugzilla 22293: Nullable should define opCast!bool
- Bugzilla 24698: Appender needs to expose readonly property 'size_t length' without using 'data' property
Druntime bug fixes
- Bugzilla 24579: stat_t has wrong size for Android armv7a
- Bugzilla 24626: hasUDA does not handle multiple UDAs of the same symbol
- Bugzilla 24660: atomic_wchar_t has wrong size on Posix
- Bugzilla 24661: wctype_t and wctrans_t are platform-dependent
Druntime enhancements
- Bugzilla 24590: Illegal instruction with module constructors cycle and shared libphobos2 in _d_criticalenter2
dlang.org bug fixes
- Bugzilla 24543: The @__future attribute is (almost) undocumented
- Bugzilla 24548: [spec] Boolean condition conversion is not documented
- Bugzilla 24565: out contract variable is implicitly const
- Bugzilla 24680: [dip1000] final auto class method infers scope but no return
- Bugzilla 24732: FAQ article is out of date on calling printf
dlang.org enhancements
- Bugzilla 24659: Memory safe D page lacks information on return ref
Installer bug fixes
- Bugzilla 24600: DMD nightly builds are outdated
Contributors to this release (38)
A huge thanks goes to all the awesome people who made this release possible.
- 0-v-0
- 0v0
- Adam Wilson
- Alex Muscar
- Amaury
- Andrei Horodniceanu
- Anita Hammer
- Ate Eskola
- Ben Jones
- Brad Roberts
- Brian Callahan
- Connor
- Denis Feklushkin
- Dennis
- Dennis Korpel
- Dennis O.
- Emmanuel Nyarko
- Iain Buclaw
- Jeremy Baxter
- Johan Engelen
- Jonathan M Davis
- Manu Evans
- Martin Kinkelin
- Mathias Lang
- Nicholas Wilson
- Nick Treleaven
- Paul Backus
- Per Nordlöw
- Quirin F. Schroll
- Quirin Schroll
- Razvan Nitu
- ryuukk
- Steven Schveighoffer
- Sönke Ludwig
- Tim Schendekehl
- Walter Bright
- Xin Wang
- zopsicle