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

previous version: 2.101.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,, 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 and running the pending_changelog target:
    make -f posix.mak pending_changelog

2.102.0 comes with 6 major changes and 39 fixed Bugzilla issues. A huge thanks goes to the 28 contributors who made 2.102.0 possible.

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

Compiler changes

  1. Deprecate the ability to call __traits(getAttributes) on overload sets

    Up until this release, __traits(getAttributes) could be called both on individual functions and on overload sets. However, in the latter case, the compiler simply collected the user defined attributes for the first lexically defined function. This behavior is error prone. Consider:

    module test;
    void fun() {}
    void fun(int) {}
    void main()
        static foreach(attr; __traits(getAttributes, fun))
            pragma(msg, attr);

    The above code will print "gigi" although there is no indication on what overload is actually queried. The first one is always picked.

    Starting with this release, this sort of usage of __traits(getAttributes) is deprecated. If a specific overload needs to be handled, __traits(getOverloads) may be used in conjunction with __traits(getAttributes) for proper behavior:

    module test;
    void fun() {}
    void fun(int) {}
    void main()
        static foreach (t; __traits(getOverloads, test, "fun"))
            static foreach(attr; __traits(getAttributes, t))
                pragma(msg, attr);

    The above code prints:

  2. Deprecate non-empty for statement Increment clause with no effect

    The last clause of a for statement should not produce a value without also having some meaningful side-effect. This is now detected with a deprecation message. The following for statements each trigger the deprecation:

    // evaluating `j` has no side-effects
    int j;
    for (;; j) {...}
    // unnecessary dereference
    for (ubyte* sp;; *sp++) {...}
    // first clause is a block statement
    // last clause is a function literal, not a block statement
    for({j = 2; int d = 3;} j + d < 7; {j++; d++;}) {...}

    Note: Calling a function returning void is not deprecated even if the function does nothing. This is for generic code.

  3. Array literals assigned to scope array variables can now be allocated on the stack

    Formerly, they were always allocated with the Garbage Collector, making it unavailable in @nogc or -betterC code. This led to frequent use of the following workaround:

    void main() @nogc
        int[3] buffer = [10, 20, 30];
        int[] arr = buffer[];

    This can now be written in a single line:

    void main() @nogc
        scope int[] arr = [10, 20, 30];

    With the following limitations:

    • The variable must be explicitly annotated scope, not just inferred scope
    • The -preview=dip1000 must be passed, to prevent introducing memory corruption in legacy code.
    Note that in @system and @trusted code, the compiler doesn't verify that your scope variable doesn't escape.
    • The array literal must be initializing the variable. Subsequent array literals assignments still use the GC.
    • The array elements may not have a destructor

    Some of these limitations might get lifted in the future.

  4. -preview=systemVariables has been added

    Since DIP 1035 - System Variables has been accepted, variables marked @system may no longer be accessed from @safe code. To avoid code breakage, the compiler will start with emitting deprecation warnings. The preview switch will turn these into errors, and it will be enabled by default in a future release.

    @system int* p;
    struct S
        @system int i;
    void main() @safe
        int x = *p; // error with `-preview=systemVariables`, deprecation otherwise
        S s;
        s.i = 0; // ditto

    Note that currently this is limited to variables explicitly marked @system, inference of @system based on a variable's initializer is yet to be implemented.

Dub changes

  1. Binary output will now be in a central cache

    Up until now, dub would output build artifact in the package directory.

    This allowed reuse of build artifact for dependencies, but also created issues with large amount of build artifacts in the packages folder, preventing the use of read-only location to store packages, and making garbage collection of build artifacts unreliable.

    Starting from this version, build artifacts will be output by default to $HOME/.dub/cache/build/$BASE_PACKAGE_NAME/$PACKAGE_VERSION/[+$SUB_PACKAGE_NAME] on Linux, and %APPDATA%/cache/build/$BASE_PACKAGE_NAME/$PACKAGE_VERSION/[+$SUB_PACKAGE_NAME] on Windows.

  2. DUB API breaking change: Package.metadataCache setter and getter have been removed

    Those two functions were used to provide access to the metadata cache file to the generator. They were never intended for public consumption, and the JSON file format was not stable.

    Due to the introduction of the build cache, they needed to be removed, as there was no way to provide a sensible transition path, and they should be unused. If you have a use case for it, please open an issue in dub repository.

List of all bug fixes and enhancements in D 2.102.0:

DMD Compiler regression fixes

  1. Bugzilla 21301: Wrong values being passed in long parameter list
  2. Bugzilla 23539: [REG master] Scope C++ definition out of sync with D

DMD Compiler bug fixes

  1. Bugzilla 13060: @nogc reading an associative array
  2. Bugzilla 15414: __traits(getAttributes) should error if the function has multiple overloads
  3. Bugzilla 15712: extern(C) attribute inside extern(C) unittest is incorrectly ignored
  4. Bugzilla 19623: HERE string identifier cannot start with Unicode letter
  5. Bugzilla 21062: Confusing error when using a keyword as an identifier for a declaration
  6. Bugzilla 21506: misalignment of _argptr for variadic functions
  7. Bugzilla 22759: ImportC: cannot modify const expression from dereferencing const pointer declared within function.
  8. Bugzilla 23412: void init member detection does not account for static arrays
  9. Bugzilla 23418: double argument is passed on stack, but assumed to be in XMM0 register
  10. Bugzilla 23447: wrong expression in error message when template instance doesn't match any overload
  11. Bugzilla 23462: dmd: src/dmd/backend/cod2.d:2158: Assertion cast(int)tysize((*e).Ety) <= REGSIZE() failed
  12. Bugzilla 23463: Don't count skipped function overloads when limiting overloads shown
  13. Bugzilla 23465: Invalid token error points to wrong line
  14. Bugzilla 23470: Backticks in diagnostic are confusing with wrong number of arguments passed
  15. Bugzilla 23491: Nonsensical deprecation message when using delegate
  16. Bugzilla 23531: [DIP1000] scope variable can be assigned as AA key
  17. Bugzilla 23534: __traits(isZeroInit) is true for enums with explicit values
  18. Bugzilla 23536: crt_constructors and crt_destructors should not be non-static member functions

DMD Compiler enhancements

  1. Bugzilla 9848: Better diagnostic when type declaration was not expected
  2. Bugzilla 21338: Confusing error message for template overload resolution failure
  3. Bugzilla 22306: scope array variable should be stack allocated
  4. Bugzilla 23410: ImportC: binary constants not allowed
  5. Bugzilla 23424: improve error when template instantiation doesn't match any overload
  6. Bugzilla 23458: No template candidates listed when OverDeclaration or OverloadSet don't match
  7. Bugzilla 23466: -verrors=context should not repeat same context for supplemental messages
  8. Bugzilla 23479: ImportC recognizes .i and .c files, but not .h files
  9. Bugzilla 23480: non-empty ForStatement Increment clause should require a side effect

Phobos bug fixes

  1. Bugzilla 23319: std.range.Generator does not work with non-mutable elements
  2. Bugzilla 23488: std.format.sformat mishandles char ranges
  3. Bugzilla 23507: Socket.blocking property incorrect on new Socket on Windows

Phobos enhancements

  1. Bugzilla 19737: [std.experimental.allocator] link table in docs has missing symbols
  2. Bugzilla 23453: Generic iota should be a forward range

Druntime enhancements

  1. Bugzilla 23332: core.sync.condition notify methods should be @nogc bug fixes

  1. Bugzilla 23382: Non-template requirement for copy constructors is undocumented
  2. Bugzilla 23436: Spec falsely states mutable references in struct .init are forbidden enhancements

  1. Bugzilla 23426: Example Run button shows wrong line numbers for errors
  2. Bugzilla 23432: document when array capacity is zero and capacity performance

Contributors to this release (28)

A huge thanks goes to all the awesome people who made this release possible.

previous version: 2.101.0