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

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



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

Compiler changes

  1. Deprecate allowing a constructor declaration in a static block

    Before patch: The language specification states that a static constructor is defined using the construction "static this()". Defining a constructor inside a static block does not have any effect on the constructor. The following code samples do not affect the constructor in any way:

    static:
        this() {}
    
    static
    {
        this() {}
    }
    

    The compiler does not issue any warning/error on the above code samples and generates a normal constructor which is not ran before the main() function. This leads to situations in which the compiler is not able to correctly indicate the problem:

    class A
    {
        static
        {
            this() {}
        }
    
        this() {}
    }
    
    void main()
    {
        new A();
    }
    

    This code will result in an error message indicating that there is a multiple definition of the constructor this() which is a misleading message.

    After patch: Whenever a constructor is encountered in a static context a deprecation message is issued stating that the static keyword does not have any effect on the constructor. The solution is to declare the constructor outside the static block either as a normal constructor or a static one (static this()).

  2. Deprecate usage of this and super as types

    Prior to this release, this and super could be used as both data or types depending on the context. Starting with this release using this or super as a type will result in a compiler error.

    class C
    {
        shared(this) x;    // Deprecation: Using `this` as a type is deprecated. Use `typeof(this)` instead
    }
    
    class D : C
    {
        shared(super) a;   // Deprecation: Using `super` as a type is deprecated. Use `typeof(super)` instead
        super b;           // Deprecation: Using `super` as a type is deprecated. Use `typeof(super)` instead
    }
    

    Use typeof(super) or typeof(this) instead.

    class C
    {
        shared(typeof(this)) x;
    }
    
    class D : C
    {
        shared(typeof(super)) a;
        typeof(super) b;
    }
    
  3. Implement DIP 1009 - Add Expression-Based Contract Syntax

    Expression-based contract syntax has been added: Contracts that consist of a single assertion can now be written more succinctly and multiple in or out contracts can be specified for the same function.

    Example:

    class C {
        private int x;
        invariant(x >= 0);
        // ...
    }
    
    int fun(ref int a, int b)
        in(a > 0)
        in(b >= 0, "b cannot be negative")
        out(r; r > 0, "return must be positive")
        out(; a != 0)
    {
        // ...
    }
    
  4. Support for iterating template overloads

    __traits(getOverloads) has been extended to return template overloads when passed an optional parameter with a true value.

    struct S
    {
        static int foo()() { return 0; }
        static int foo()(int n) { return 1; }
        static int foo(string s) { return 2; }
        enum foo(int[] arr) = arr.length;
    }
    
    alias AliasSeq(T...) = T;
    
    alias allFoos = AliasSeq!(__traits(getOverloads, S, "foo", true));
    
    static assert(allFoos.length == 4);
    
    static assert(allFoos[0]("") == 2);
    static assert(allFoos[1]() == 0);
    static assert(allFoos[2](1) == 1);
    alias foo3 = allFoos[3];
    static assert(foo3!([]) == 0);
    
  5. __traits(getLinkage, ...) now works on structs, classes, and interfaces.

    It is now possible to detect the language ABI specified for a struct, class, or interface.

    class MyClass {}
    extern (C++) struct MyCPPStruct {}
    extern (C++) interface MyCPPInterface {}
    static assert(__traits(getLinkage, MyClass) == "D");
    static assert(__traits(getLinkage, MyCPPStruct) == "C++");
    static assert(__traits(getLinkage, MyCPPInterface) == "C++");
    
  6. Implicit catch statements will now result in an error

    See the Deprecated Features for more information.

    Implicit catch statements were deprecated in 2.072. Starting with this release, implicit catch statements will cause the compiler to emit an error.

    import std.stdio;
    
    void main()
    {
        int[] arr = new int[](10);
        // This will throw a RangeError
        try { arr[42]++; }
        catch  // Error: `catch` statement without an exception specification is deprecated;
               // use `catch(Throwable)` for old behavior
        {
            writeln("An error was caught and ignored");
        }
    }
    
  7. Implicit comparison of different enums will now result in an error

    See the Deprecated Features for more information.

    Implicit comparison of different enums was deprecated in 2.075. Starting with this release, implicit comparison of different enums will cause the compiler to emit an error.

    enum Status
    {
        good,
        bad
    }
    enum OtherStatus
    {
        ok,
        no
    }
    static assert(Status.good == OtherStatus.ok); // Error: Comparison between different enumeration types `Status` and `OtherStatus`;
                                                  // If this behavior is intended consider using `std.conv.asOriginalType`
    
  8. Implicit string concatenation will now result in an error

    See the Deprecated Features for more information.

    Implicit string concatenation was deprecated in 2.072. Starting with this release, implicit string concatenation will cause the compiler to emit an error.

    void main()
    {
        string s = "Hello" ", World!";  // Error: Implicit string concatenation is deprecated, use "" ~ "" instead
    }
    
  9. IRETQ is now supported in inline assembler.

    IRETQ is the 64-bit version of the already supported IRET instruction. With its inclusion, it is now possible to write 64-bit interrupt service routines in pure D.

    void isr()
    {
        asm
        {
            naked;
            // ...
            iretq;
        }
    }
    
  10. extern (C++) now mangles class constructor's correctly.

    extern (C++) mangling of class constructor is working, also virtual and non-virtual destructors mangle correctly too. C++ semantics are not yet perfectly matching, but some simple cases are working.

  11. extern (C++) is now able to mangle typeof(null) (aka: nullptr_t) which often appears in C++ API's.
    alias nullptr_t = typeof(null);
    extern (C++) void fun(nullptr_t);
    
  12. extern (C++) operators now mangle correctly.

    extern (C++) mangling of operators is working for all operators that are semantically equivalent. This list includes all instantiations of opUnary, opBinary, opAssign, opOpAssign, opCast, opEquals, opIndex, opCall. Two notable exceptions are opCmp, and C++ operator !, which don't have compatible implementations.

  13. Interfaces and classes can be used without the runtime if only static fields are utilized

    Prior to this release any attempt to use interfaces and/or classes without the runtime would result in compile-time errors due to the lack of TypeInfo. However, as long as classes are not instantiated there is no need for TypeInfo.

    Beginning with this release the compiler will no longer emit errors about missing TypeInfo when using interfaces and/or classes as long as they are not instantiated and only shared static members are utilized.

    Example 1

    module object
    
    private alias extern(C) int function(char[][] args) MainFunc;
    private extern (C) int _d_run_main(int argc, char** argv, MainFunc mainFunc)
    {
        return mainFunc(null);  // assumes `void main()` for simplicity
    }
    
    interface I
    {
        shared static int i;
    }
    
    class A : I
    {
        shared static int a;
    }
    
    class B : A
    {
        shared static int b;
    }
    
    void main()
    {
        B.b = B.a + B.i;
    }
    

    dmd -conf= -defaultlib= main.d object.d -of=main
    size main
       text    data     bss     dec     hex filename
       1867    1208      32    3107     c23 main
    

    Non-shared static members can also be used, but will require a thread-local storage (TLS) implementation. For example, on Linux the TLS implementation is already supplied by the C runtime and C standard library, so, since dmd automatically calls gcc to link the final executable, it will automatically bring in the TLS implementation.

    Example 2

    module object
    
    private alias extern(C) int function(char[][] args) MainFunc;
    private extern (C) int _d_run_main(int argc, char** argv, MainFunc mainFunc)
    {
        return mainFunc(null);  // assumes `void main()` for simplicity
    }
    
    interface I
    {
        static int i;
    }
    
    class A : I
    {
        static int a;
    }
    
    class B : A
    {
        static int b;
    }
    
    void main()
    {
        B.b = B.a + B.i;
    }
    

    dmd -conf= -defaultlib= main.d object.d -of=main
    size main
       text    data     bss     dec     hex filename
       2123    1296      28    3447     d77 main
    

    Some platforms may require some TLS implementation code or some specialized build procedures to link in a TLS implementation.

    This will hopefully reduce friction for those using D without the runtime, porting D to new platforms, or using D from other langauges, while enabling more features and idioms of D to be used in those use cases.

  14. Specifying redundant storage classes will now result in a compiler error

    Specifying redundant storage classes was deprecated long ago and was originally scheduled to emit a compiler error beginning with the 2.068 release. That promise has been fulfilled with this release.

    @safe void f() @safe {}   // Error: redundant attribute `@safe`
    

Runtime changes

  1. Filenames and line numbers have been added to stacktraces on macOS

    When an exception is throw and not caught, a stacktrace is printed. On Linux, FreeBSD and DragonFlyBSD this stacktrace includes the filenames and line numbers, if the application was built with debug info enabled. This feature has now been added to macOS.

    This requires support from the compiler since debug info is stripped by the linker on macOS.

    Example:

    void bar()
    {
        throw new Exception("bar");
    }
    
    void foo()
    {
        bar();
    }
    
    void main()
    {
        foo();
    }
    

    Compiling the above code, with debug info enabled, by running: dmd -g main.d. When running the application it will produce an output similar to:

    object.Exception@main.d(3): bar
    

    main.d:3 void main.bar() [0x71afdfb] main.d:8 void main.foo() [0x71afe0c] main.d:13 _Dmain [0x71afd78]

  2. object.destroy() supports extern(C++) classes.

    object.destroy() was crashing when called with an extern(C++) class. It now correctly destructs and resets the object to init.

  3. Add missing declarations to core.sys.darwin.mach.getsect

    Declarations that were missing from mach-o/getsect.h has been added to core.sys.darwin.mach.getsect.

Library changes

  1. The deprecated std.c package has been removed.

    Use the core.stdc package instead.

  2. std.algorithm.mutation.remove now only accepts integral values or pair of integral values as offset

    Previously, without being stated in the documentation, std.algorithm.remove used to accept any values as offset. This behavior was very error-prone:

    import std.algorithm, std.stdio;
    [0, 1, 2, 3, 4].remove(1, 3).writeln; // 0, 2, 4  -- correct
    [0, 1, 2, 3, 4].remove([1, 3]).writeln; // 0, 3, 4  -- incorrect
    

    With this release, using arrays as individual elements is no longer valid. std.typecons.tuple can be used to explicitly indicate that a range from start to stop (non-enclosing) should be removed:

    import std.algorithm, std.stdio, std.typecons;
    [0, 1, 2, 3, 4].remove(tuple(1, 3)).writeln; // 0, 3, 4
    

    However, only 2-tuples are allowed to avoid this un-intuitive scenario:

    import std.algorithm, std.stdio, std.typecons;
    [0, 1, 2, 3, 4].remove(tuple(1, 3, 4)).writeln; // 0, 4?
    
  3. Changed semantics of std.math.{fmin,fmax} wrt. NaNs.

    The semantics of std.math.fmin and std.math.fmax have been streamlined with the C functions: if one of the arguments is a NaN, return the other. This involves an additional std.math.isNaN check. Use std.algorithm.comparison.min and std.algorithm.comparison.max for the previous semantics performing a single comparison.

    import std.math;
    assert(fmin(real.nan, 2.0L) == 2.0L);
    assert(fmin(2.0L, real.nan) == 2.0L); // previously: NaN
    assert(isNaN(fmin(real.nan, real.nan)));
    
    import std.algorithm.comparison;
    assert(min(real.nan, 2.0L) == 2.0L);
    assert(isNaN(min(2.0L, real.nan)));
    assert(isNaN(min(real.nan, real.nan)));
    

Dub changes

  1. DUB supports "customCachePaths" for providing read-only package paths

    With this release DUB allows defining additional paths that contain packages in subfolders with the pattern "(name)-(version)/(name)/" by defining a "customCachePaths" field in /etc/dub/settings.json or ~/.dub/settings.json.

    "customCachePaths" can be used to provide prebuilt DUB libraries (e.g. for distribution package maintainers).


List of all bug fixes and enhancements in D 2.082.0:

DMD Compiler regressions

  1. Bugzilla 18821: DMD segfault when doing unsafe operation outside of any function
  2. Bugzilla 18905: [Reg 2.079] C++ classes can no longer be used with -betterC
  3. Bugzilla 18936: Internal error: dmd/backend/cgxmm.c 684

DMD Compiler bugs

  1. Bugzilla 5153: Struct pointer to struct variable assign error message
  2. Bugzilla 7443: Better diagnostic on wrongly written static constructor
  3. Bugzilla 11742: cannot inizialize void initialized static variable in static constructor.
  4. Bugzilla 12764: Disabled struct default construction circumvented when field is written to
  5. Bugzilla 12807: UFCS checks "alias this" attributes even when not called
  6. Bugzilla 13435: Strange error if struct is a class member and opAssign applied
  7. Bugzilla 13741: std.traits.moduleName & packageName do not work with functions that have parameters
  8. Bugzilla 14178: C++ linux name mangling does not handle standard abbreviations for const types
  9. Bugzilla 15068: wrong error message on attempting to use type as template
  10. Bugzilla 15388: extern(C++) - typeof(null) should mangle as nullptr_t
  11. Bugzilla 15475: Ddoc code sample with unbalanced paren comes out as macro
  12. Bugzilla 15574: wrong order of linker arguments
  13. Bugzilla 15755: DMD segfault upon alias on alias on __trait(getAttributes, ...)
  14. Bugzilla 15869: RVO can overwrite argument
  15. Bugzilla 16088: Parse error for import expression in statement
  16. Bugzilla 16206: traits getOverloads fails when one of the overload is a templatized function
  17. Bugzilla 17373: traits getOverloads + multiple interface inheritance only see one of the interfaces' overloads
  18. Bugzilla 18228: this(this a){} doesn't generate postblit ctor; this(this){} does
  19. Bugzilla 18236: Invalid line reported on error casting enum
  20. Bugzilla 18365: header file generation doesn't include the return attribute
  21. Bugzilla 18584: Undefined identifier when not specifying 'this'
  22. Bugzilla 18730: dmd miscompiles core.bitop.bt with -O
  23. Bugzilla 18746: function returning empty struct isn't called if used in equality expression
  24. Bugzilla 18775: DMD falsely reports deprecation for deprecated implicit casts that were not used in UFCS
  25. Bugzilla 18803: just "static if" in nested import crashes dmd
  26. Bugzilla 18828: [-betterC] helpless error in object.d
  27. Bugzilla 18858: switch 'skips declaration' test only checks last declaration
  28. Bugzilla 18868: Separate compilation generates two static this functions, runs it twice
  29. Bugzilla 18888: extern(C++) template arg/alias arg mangling issue
  30. Bugzilla 18890: extern(C++) mangles all destructors the same
  31. Bugzilla 18891: extern(C++) destructor prototype should just link; not generate field/aggregate dtor
  32. Bugzilla 18892: Wrong type in error message for static members and alias this
  33. Bugzilla 18922: dmd doesn't do substitutions for C++ namespaces in different module/file
  34. Bugzilla 18928: extern(C++) bad codegen, wrong calling convention
  35. Bugzilla 18951: package static method masked by public static method in class
  36. Bugzilla 18957: extern(C++) doesn't mangle 'std' correctly on posix systems
  37. Bugzilla 18970: DMD segfault due to opDispatch
  38. Bugzilla 18976: Inconsistency in overload merging with aliases

DMD Compiler enhancements

  1. Bugzilla 14086: Invalid extern C++ name for constructor / destructor
  2. Bugzilla 15589: extern(C++) virtual destructors are not put in vtbl[]
  3. Bugzilla 15691: Improve error message for struct member initializer
  4. Bugzilla 18859: Silence class allocator/deallocator deprecation warning if they are marked "deprecated"
  5. Bugzilla 18963: Relax restrictions on 'return' parameters when parameter is not a pointer
  6. Bugzilla 18994: Use noncopyable variable in foreach loop without ref results in error message without line number

Phobos bugs

  1. Bugzilla 12086: std.algorithm.remove + range of indices produces wrong results
  2. Bugzilla 17084: Can't sort array of structs with alias this: swap can't call non-@nogc function doesPointTo
  3. Bugzilla 17806: processAllocator getter will override set value if it was set before getter was called at least once
  4. Bugzilla 18415: Typedef ignores @disabled default constructor
  5. Bugzilla 18470: std.algorithm.splitter has frame access problems for custom preds
  6. Bugzilla 18525: Constraint on std.algorithm.mutation.remove fails with char[]
  7. Bugzilla 18760: theAllocator should hold a reference to the allocator that it uses
  8. Bugzilla 18804: std.algorithm.mutation.copy puts whole source range into target range when it should put elements
  9. Bugzilla 18847: std.allocator: Region uses .parent before it can be set
  10. Bugzilla 18933: std.range.assumeSorted should not nest SortedRange!(SortedRange!(...), pred)
  11. Bugzilla 18934: std.concurrency receive throws assertion failure if message is a struct containing const data
  12. Bugzilla 18940: [std.net.curl]Can't run examples on page. cannot implicitly convert expression ... char[] to string
  13. Bugzilla 18952: std.experimental.checkedint.Saturate prints integral promotion deprecation message

Phobos enhancements

  1. Bugzilla 18178: std.path should be usable in @safe
  2. Bugzilla 18593: std.datetime.stopwatch.benchmark shouldn't optimize away its functions
  3. Bugzilla 18766: std.typecons.Tuple.toHash could be improved
  4. Bugzilla 18813: fromStringz should work with char, wchar and dchar
  5. Bugzilla 18837: MMFile should have opDollar
  6. Bugzilla 18948: std.uni.toLower and std.uni.toUpper should work with random access ranges

Druntime bugs

  1. Bugzilla 14536: Calling destroy() on a on an extern(C++) class causes a segfault
  2. Bugzilla 18932: core.internal.hash.hashOf(val, seed) ignores seed when val is a raw pointer
  3. Bugzilla 18989: On OSX32, core.stdc.time.clock() should resolve to clock$UNIX2003()

Druntime enhancements

  1. Bugzilla 18768: object.getArrayHash with custom toHash shouldn't just sum hashes of array elements
  2. Bugzilla 18920: core.internal.hash of array of scalars should be @safe
  3. Bugzilla 18923: Semaphore internal handle should be protected instead of private
  4. Bugzilla 18924: Use addition rather than XOR for order-independent hash combination
  5. Bugzilla 18925: core.internal.hash auto-hash for structs of scalar fields should be @safe
  6. Bugzilla 18943: core.internal.hash remove outdated special case for DMD unaligned reads

dlang.org bugs

  1. Bugzilla 18558: Template alias spec incomplete
  2. Bugzilla 18752: std.file.read runnable example fails
  3. Bugzilla 18761: Page for assumeUnique documentation displays incorrectly
  4. Bugzilla 18782: Documentation error: ProtectionAttributes should say Visibility Attributes

dlang.org enhancements

  1. Bugzilla 14099: Promote DPaste (dpaste.dzfl.pl) to run.dlang.org
  2. Bugzilla 18869: Add Jumia Food to organizations using D
  3. Bugzilla 18874: Add thatneedle.com to organizations using D
  4. Bugzilla 18959: [Change Log: 2.079.0] substitute was added in std.algorithm.iteration but the changelog points to std.algorithm.searching

Contributors to this release (54)

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

previous version: 2.080.1