Report a bug
If you spot a problem with this page, click here to create a GitHub 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.116.0

previous version: 2.114.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


2.116.0 comes with 19 major changes and 0 fixed GitHub issues. A huge thanks goes to the 0 contributors who made 2.116.0 possible.

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

Compiler changes

  1. C++ classes can derive from extern(C++) classes defined in D on Itanium C++ ABI targets

    The Itanium C++ ABI (used on Linux, macOS, the BSDs and other POSIX targets) gives each constructor and destructor two variants: the complete-object one, which constructs or destroys a whole object, and the base-object one, which a derived class uses for its base subobject. DMD only emitted the complete-object variants, so a C++ class deriving from an extern(C++) class defined in D failed to link.

    DMD now also emits the base-object variants for every extern(C++) constructor and destructor, and a D class uses the base-object variants of its C++ base class, as C++ does.

    // D
    extern(C++) class Base
    {
        this() { }
        ~this() { }
        int id() { return 1; }
    }
    
    // C++
    class Base
    {
    public:
        Base();
        virtual ~Base();
        virtual int id();
    };
    
    class Derived : public Base
    {
    public:
        Derived() { }           // calls Base::Base(), the base-object constructor
        ~Derived() { }          // calls Base::~Base(), the base-object destructor
        int id() { return 2; }
    };
    
  2. The fast DFA engine has gained a borrow checker

    The fast DFA engine's escape analysis can now track borrows, protecting against mutation of, and outliving, the borrowed-from object.

    A function signals that its return value borrows from a parameter (or from this, when placed on the function) by annotating it with the __fastdfa_returnborrow attribute:

    import core.attribute : __fastdfa_returnborrow;
    
    struct Buffer
    {
        int* data;
    
        // return borrows from `this`
        int* get() @__fastdfa_returnborrow => data;
    }
    
    void methodOutliveErr()
    {
        int* b;
        {
            Buffer s;
            b = s.get(); // error: borrow of `this` outlives the owner
        }
    }
    

    The borrow checker enforces the following protections at the call site:

    • The owner of an active borrow cannot have a reference-typed value reassigned while the borrow is alive.
    • A borrow variable cannot be changed (reassigned, set to null, etc.) unless it is declared inside the loop it is changed in.
    • A borrow cannot outlive the variable it borrows from (including being returned from a function when the borrow is of a stack local).
    • The owner of an active borrow may not be passed to a function whose parameter could mutate it; the parameter must be const/immutable where it reaches the cell.
    • Storing a borrow through a dereference is rejected in @safe code.

    It is intended to protect reference counting types, and gates the introduction of reference counting in language. It may be used to protect other forms of borrowing such as by-ref match expressions for sumtypes.

    Unlike traditional borrow checkers (such as Rust's or D's @live) which focus primarily on aliasing guarantees through whole-function analysis, this implementation permits aliasing. Instead, it focuses on intra-procedural flow checks to safeguard reference-counted types and safely enable potential future language features (such as language-level reference counting and by-ref match expressions for sumtypes).

    While @live relies on DIP1000 annotations (scope, return, return ref), this feature builds directly on the fast DFA engine's abstract points-to graph, offering richer modeling of how memory moves through code. Currently the engine's escape analysis does not offer in language attributes, so the UDA __fastdfa_returnborrow is required, however it would slot into any future syntax cleanly.

    No breaking changes are expected. This is an opt-in feature of the fast DFA engine, which itself is opt-in.

    This is an experimental feature, enabled with the -preview=fastdfa switch. It is subject to change and may be removed at a later date.

  3. -deps no longer runs full semantic analysis on all imported modules

    -deps used to force semantic analysis of every function body in every imported module, just to find more dependencies. That made -deps behave partly like -i without actually compiling those modules. It slowed things down, listed dependencies that don't matter for incremental builds, and could cause errors from library code that wasn't being compiled, like -betterC errors from druntime.

    Now -deps only reports what normal compilation finds. Imports inside function bodies of modules that aren't being compiled are no longer followed. To get the full transitive list, use -deps together with -i.

  4. The generated invariant is now accessible as __invariant

    The function the compiler generates to run an aggregate's invariant blocks can now be referred to as __invariant, like the generated destructor as __xdtor, and is listed by __traits(allMembers).

  5. Give informational message about use of default NaN initializers

    Adding the compiler switch -vnan will cause the compiler to emit messages where the compiler default initializes a floating point value to NaN.

    float f;
    void test() { float g; }
    struct S { float h; }
    cfloat cf;
    

    This is an informational message only, it does not alter the generated code.

  6. Fully qualified self-reference inside package.d no longer requires static import

    Previously, referring to a package's own fully qualified name from inside its package.d module incorrectly required adding a static import of itself, even though unqualified access already worked without it.

    // bug/buggier/package.d
    module bug.buggier;
    
    void fn() {}
    
    void main()
    {
        bug.buggier.fn(); // used to require `static import bug.buggier;`
    }
    
  7. Unary + is now allowed in array operations

    Arrays already supported the unary - and ~ vector operations. Unary + is now supported too, with the same rules:

    int[4] a = [1, -2, 3, -4];
    int[4] b = +a[];    // previously: illegal operator `+` for `a[]` of type `int[]`
    b[] = +a[] * 2;
    
  8. Add new flag -unittest-roots

    Besides the existing -unittest flag dmd now also takes the accompanying flag -unittest-roots. When passed, only the unittests placed in the (root) source files X... being explicitly passed to the call to dmd are processed like when -unittest is passed. All other unittests placed in (non-root) modules not present in X that are (transitively) imported in X source files (when -i is passed) will not be processed.

  9. Add vasm=<string> option to -vasm compiler switch

    The existing use of vasm will print a disassembly of all functions being compiled. This can result in an unmanageably large amount of output. The addition of `= enables specification of a pattern (a simple string) that is matched against a function's mangled name. If it is a match, it is disassembled and displayed.

Runtime changes

  1. New core.gc.monitor module to observe GC allocations and deallocations at runtime

    The new core.gc.monitor module allows tooling such as memory profilers to receive a callback for every GC allocation and for every block freed, including blocks reclaimed during a collection, as well as after each completed collection.

    import core.gc.monitor;
    
    pragma(crt_constructor) void registerMonitors()
    {
        setGCMonitor(&onAlloc, &onFree);
    }
    
    void onAlloc(void* ptr, size_t size) nothrow @nogc { /* ... */ }
    void onFree(void* ptr, size_t size, bool collected) nothrow @nogc { /* ... */ }
    

    The callbacks run from inside the GC — with the GC lock held, or with all threads suspended during a collection — so they must be nothrow @nogc and must not allocate or call back into the GC. Only the conservative GC (the default) reports to the monitors at the moment.

  2. Add core.bitop.isRightJustifiedOnes

    core.bitop.isRightJustifiedOnes checks whether the set bits of an unsigned integer form a single, contiguous run of 1s starting at the least significant bit (e.g. 0, 0b0111, 0x00FF_FFFF). This is a common need, but the efficient implementation is not obvious.

    import core.bitop : isRightJustifiedOnes;
    
    assert( isRightJustifiedOnes(0x00FF_FFFFu));
    assert(!isRightJustifiedOnes(0x1010_1110u));
    
  3. TypeInfo_Class.vtbl and Interface.vtbl have been removed

    These opaque void*[] tables are hardly useful and have been removed to make class TypeInfos slightly leaner, and prepare for generating the TypeInfo in library code.

    If really needed, the pointer to the vtable of a class (the vptr) is stored at the start of each class instance, including init symbol. E.g.:

    // for a dynamic type:
    immutable(void*)* vptr = myObject.__vptr;
    // for a static type:
    immutable(void*)* vptr = *cast(immutable(void*)**) __traits(initSymbol, MyClass).ptr;
    
  4. core.time.TickDuration has been removed.

    The TickDuration type was deprecated in 2.104.0, and is now removed from druntime. Instead, you should use core.time.MonoTime

  5. Discover individual unittest blocks through ModuleInfo

    ModuleInfo.unitTests exposes a read-only array of pointers to immutable UnitTestInfo records containing a record size, function pointer, and compiler-generated name. Entries follow the order used by the existing ModuleInfo.unitTest wrapper. This enables custom runners to discover and invoke individual tests without changing the default runner's behavior.

    Generated names are not guaranteed unique or stable across builds. Metadata is empty for modules without emitted tests and modules built by older compilers; such older modules may still provide a unitTest wrapper.

    Records have module lifetime. Future fields can be appended; consumers must check the emitted record's size before reading newer fields.

  6. The default unittest runner now runs each unittest block on its own

    Previously all the unittest blocks of a module were run as one, so the first failure skipped the remaining blocks of that module, and results were counted in modules. The default runner now uses ModuleInfo.unitTests to run every block individually and carries on after a failure.

    Progress is reported on stderr, with one line per module followed by a summary. A failing unittest is named before its failure is printed, with a stack trace unless the failure is an assertion in the unittested module's own file (see below):

    pkg.mod.__unittest_L7_C1: FAILED
    core.exception.AssertError@pkg/mod.d(9): boom
    ----------------
    

    ??:? [0x5608992fb290] ??:? [0x5608992fa64f] ... pkg.mod: 1 passed, 1 FAILED pkg.other: 1 passed 1/3 unittests FAILED

    When an assertion fails in the file of a top-level module, the short file(line): [unittest] message form is printed without a stack trace, as before, but it is now written to stderr instead of stdout. The summary wording changes from N modules passed unittests and F/N modules FAILED unittests to N unittests passed and F/N unittests FAILED, which matters to scripts matching the old text. Because the remaining unittests still run after a failure, a unittest may now run after an earlier one in the same module failed, where previously it was skipped. main is still only run when there are no unittests. To revert to the previous runner, with unittests run and counted per module and its output unchanged, pass --DRT-testmode=test-or-main to the program:

    ./app --DRT-testmode=test-or-main

    or embed the option in the executable so that it applies to every run:

    extern(C) __gshared string[] rt_options = ["testmode=test-or-main"];

    test-or-main is what the runner did by default before this change. The other --DRT-testmode values, run-main and test-only, also select the previous runner and keep their meaning. Custom handlers set with Runtime.moduleUnitTester or Runtime.extendedModuleUnitTester are not affected.

Library changes

  1. std.datetime.stopwatch is now publicly imported when you import std.datetime

    This omission was in place since std.datetime.stopwatch was introduced, as std.datetime.stopwatch.benchmark conflicted with std.datetime.benchmark.

    The latter was removed in 2021 (2.075).

Dub changes

  1. Add optional compiler invocation timing reports

    dub build, dub run, and dub test now accept --build-timings. The report is printed to standard error, including with --quiet, after the direct build stage and before application or test execution. If compilation or linking fails, a partial report includes completed and failed invocations without changing the build's failure status.

    dub build --build-mode=singleFile --parallel --build-timings
    dub test --build-mode=singleFile --parallel --build-timings
    

    For example, a parallel build of a package named example with two source files printed this timing report:

    Build timings (completed)
      Elapsed ms    Start ms      End ms  Status       Phase         Target / sources
         564.390      56.935     621.325  ok           link          example
          51.025       5.605      56.630  ok           compile       example / source/app.d
          49.139       6.097      55.236  ok           compile       example / source/helper.d
      Summed invocation time: 664.554 ms (3 invocations; parallel jobs overlap).
      Build stage elapsed: 624.678 ms (excludes application/test execution).
      Start/end offsets are relative to timing collection start; rows are slowest first.
    

    Rows show elapsed wall time, start/end offsets, exit status, invocation phase, target package, and explicit source inputs, sorted by decreasing elapsed time. The status no status means that launching or waiting for the process failed without obtaining an exit status. Measurements include process launch and waiting for completion, but exclude worker queueing, command preparation, and output callbacks. Source inputs do not include every transitively imported module. A combined target's package label identifies the target owner, not necessarily the owner of every source.

    Use --build-mode=singleFile for individual source timings. Other modes may compile multiple sources together or combine compilation and linking. Library creation may be included in a compile invocation. Cached targets produce no invocation records; --force requests a rebuild. Enabling timings does not change build cache keys or force recompilation.

    Summed invocation time counts overlapping parallel jobs separately. Build-stage elapsed time includes direct build setup, cache checks, build commands and file operations, but excludes earlier package configuration, application/test execution, and report formatting. Start/end offsets begin when the collector is created.

    --rdmd is unsupported and rejected with this option. Compiler probes and commands launched by build hooks are not instrumented. Custom compiler implementations participate when they use DUB's shared process runner.

    Use --build-timings-file=PATH to write a JSON report. A relative path is resolved from the directory where you invoke DUB. The parent directory must exist. New reports are created with owner-only access. Use the file option alone for JSON, or add --build-timings for both JSON and terminal output:

    dub test --build-mode=singleFile --parallel --build-timings --build-timings-file=timings.json
    

    For example, a build that compiled and linked one source file in a single invocation produced this report (source path shortened):

    {
      "schemaVersion": 1,
      "completed": true,
      "buildElapsedNs": 1436907600,
      "summedInvocationNs": 1403419800,
      "invocations": [{
        "package": "example",
        "phase": "compile+link",
        "sources": ["source/app.d"],
        "startOffsetNs": 16764600,
        "endOffsetNs": 1420184400,
        "elapsedNs": 1403419800,
        "exitStatus": 0
      }]
    }
    

    Times are integer nanoseconds. Offsets use the same monotonic origin as the terminal report. Phases are compile, link, or compile+link. Exit status is an integer, or JSON null if no process status was obtained.

    DUB replaces the file after the direct build stage, before running the program or tests. Cached builds can produce an empty invocation list. When dub test skips a package with target type none, it writes a completed report with zero build time and no invocations. A failure in the direct build stage writes a partial report with completed set to false. Failures before that stage, such as an invalid package recipe, leave any previous report in place. If the requested file cannot be written, DUB reports the error and exits unsuccessfully.

  2. Skip format selection when initializing with --format

    Interactive dub init no longer asks for a package recipe format when the format was already selected with --format.

  3. Refuse to load npm package.json files.

    For historic reasons Dub treated package.json as an alias for dub.json. When a Node/npm package.json was present and no dub.json/dub.sdl was found, Dub parsed it anyway, emitted confusing unknown-key warnings, and often failed with an empty-library / targetType: none error.

    Dub now refuses to load a file named package.json when it contains npm-only top-level keys (packageManager, scripts, devDependencies, workspaces, or private). Legacy Dub recipes that still use the package.json filename continue to work. Prefer dub.json or dub.sdl for new packages.

    #3118


List of all bug fixes and enhancements in D 2.116.0:
previous version: 2.114.0