Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

Change Log: 2.111.0

previous version: 2.109.1

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


2.111.0 comes with 18 major changes and 74 fixed Bugzilla issues. A huge thanks goes to the 38 contributors who made 2.111.0 possible.

List of all upcoming bug fixes and enhancements in D 2.111.0.

Compiler changes

  1. 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;
    }
    
  2. 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.

  3. 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
    }
    
  4. 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`)
    }
    
  5. 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
    {
    }
    
  6. 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

  7. 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

  8. 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");
    
  9. 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.

  10. 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
    
  11. 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=.).

  12. 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
    }
    
  13. 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));
    }
    
  14. 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

  1. 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.

  2. 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

  1. 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

  1. 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

  1. Bugzilla 12885: const union wrongly converts implicitly to mutable
  2. Bugzilla 16643: CTFE internal error with null
  3. Bugzilla 17148: Copying from const(void)[] to void[] breaks immutable
  4. Bugzilla 21995: Struct with size uint.max or greater causes ICE
  5. Bugzilla 23294: [dip1000] parameter to parameter assignment leads to incorrect scope inference
  6. Bugzilla 23830: Azure failure for OMF: Module name not printed before struct symbol
  7. Bugzilla 23841: isZeroInit does not take into account unions
  8. Bugzilla 23957: Casting to derived extern(C++) class is unsafe
  9. Bugzilla 24375: ImportC: .di generator outputs C expression with -> operator
  10. Bugzilla 24447: ImportC: extern symbols cannot have initializers
  11. Bugzilla 24534: Having a label on a declaration makes it possible to skip it with goto
  12. Bugzilla 24558: C asserts segfault on Glibc
  13. Bugzilla 24577: Struct with constructor returned from C++ wrong
  14. Bugzilla 24582: Detect unsafe cast(bool[])
  15. Bugzilla 24583: di generator emits return scope and scope return in wrong order
  16. Bugzilla 24592: ImportC: Bitfield layout wrong for int64 on 32-bit Linux
  17. Bugzilla 24594: ImportC: Packed struct has wrong layout
  18. Bugzilla 24603: Can copy from non-void array into void[] in safe code
  19. Bugzilla 24622: Modify const data with void[] concatenation/append
  20. Bugzilla 24630: Casting a bool pointer to a mutable pointer type is unsafe
  21. Bugzilla 24631: Pointer cast allows changing @system field in @safe code
  22. Bugzilla 24634: Parse error initializing array from expression with StructInitializer
  23. Bugzilla 24651: Bitfield layout wrong for 48-bit field on 32-bit Linux
  24. Bugzilla 24663: dip1000 doesn't check slice expression implicitly converted to static array
  25. Bugzilla 24669: ImportC: C files are not compiled with '-i' flag
  26. Bugzilla 24670: importC: .di generation does not place parentheses around const struct return types
  27. Bugzilla 24694: [DIP1000] can escape stack pointer through struct.class.field
  28. Bugzilla 24701: No error produced from casted noreturn variable
  29. Bugzilla 24705: Arguments of synchronized method are unintentionally treated as shared with -preview=nosharedaccess
  30. Bugzilla 24706: Missing errors for first operand of comma expression
  31. Bugzilla 24707: error message has bad parameter attribute order
  32. Bugzilla 24733: ImportC: #pragma pack(pop) restores wrong alignment
  33. Bugzilla 24748: DMD can't output object files with fully qualified name, making -od overwirte each other file
  34. Bugzilla 24762: @nogc false positive error
  35. Bugzilla 24776: Struct with anonymous union has wrong isZeroInit
  36. Bugzilla 24803: __traits(location) is inconsistent with modules

DMD Compiler enhancements

  1. Bugzilla 9997: Missed misspell suggestions for UFCS
  2. Bugzilla 20243: inout not substituted for in associative array key type
  3. Bugzilla 21564: Allow assignment syntax for instantiating mixin templates
  4. Bugzilla 23449: spellchecker should suggest corrections for pointer members
  5. Bugzilla 23812: ImportC: allow adding function attributes to imported C functions
  6. Bugzilla 24135: Eponymous template member overloads not shown as call candidates
  7. Bugzilla 24580: ImportC: Asm label after attributes results in syntax error
  8. Bugzilla 24598: OpenBSD: adapt compiler tests
  9. Bugzilla 24623: Rename version CppRuntime_Clang/Gcc to CppRuntime_libcxx/libstdcxx.
  10. Bugzilla 24639: ImportC: defines of negative constants not detected for enum conversion
  11. Bugzilla 24645: Hidden static assert error messages if more than 20 errors
  12. Bugzilla 24738: Import core.interpolation suggestion
  13. Bugzilla 24749: A clause consisting only of "throw" should be the unlikely path

Phobos bug fixes

  1. Bugzilla 14138: std.parallelism.task breaks @safety
  2. Bugzilla 15315: can break immutable with std.algorithm.move
  3. Bugzilla 20870: std.outbuffer.printf is trusted
  4. Bugzilla 20872: std.array.assocArray trusts user-provided 'front' for values
  5. Bugzilla 23300: std.array : array wrongly propagates scopeness of source
  6. Bugzilla 24564: std.file.DirEntry throws Exception instead of FileException
  7. Bugzilla 24667: goo.gl is going away
  8. Bugzilla 24685: std.stdio.File.rawRead allows reading raw pointers from files in @safe code
  9. Bugzilla 24704: The error message for DateTime.fromISOExtString says that valid ISO extended strings that it does not support are invalid ISO extended strings
  10. Bugzilla 24715: std/process: Default to libc closefrom in spawnProcessPosix
  11. Bugzilla 24773: Stable sort() invokes the destructor on uninitialized elements

Phobos enhancements

  1. Bugzilla 22293: Nullable should define opCast!bool
  2. Bugzilla 24698: Appender needs to expose readonly property 'size_t length' without using 'data' property

Druntime bug fixes

  1. Bugzilla 24579: stat_t has wrong size for Android armv7a
  2. Bugzilla 24626: hasUDA does not handle multiple UDAs of the same symbol
  3. Bugzilla 24660: atomic_wchar_t has wrong size on Posix
  4. Bugzilla 24661: wctype_t and wctrans_t are platform-dependent

Druntime enhancements

  1. Bugzilla 24590: Illegal instruction with module constructors cycle and shared libphobos2 in _d_criticalenter2

dlang.org bug fixes

  1. Bugzilla 24543: The @__future attribute is (almost) undocumented
  2. Bugzilla 24548: [spec] Boolean condition conversion is not documented
  3. Bugzilla 24565: out contract variable is implicitly const
  4. Bugzilla 24680: [dip1000] final auto class method infers scope but no return
  5. Bugzilla 24732: FAQ article is out of date on calling printf

dlang.org enhancements

  1. Bugzilla 24659: Memory safe D page lacks information on return ref

Installer bug fixes

  1. 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.

previous version: 2.109.1