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

previous version: 2.083.1 – next version: 2.084.1

Download D 2.084.0
released Jan 01, 2019

2.084.0 comes with 21 major changes and 100 fixed Bugzilla issues. A huge thanks goes to the 53 contributors who made 2.084.0 possible.

List of all bug fixes and enhancements in D 2.084.0.

Compiler changes

  1. Aliases can be created directly from a __trait.

    Aliases can be created directly from the traits that return symbol(s) or tuples. This includes getMember, allMembers, derivedMembers, parent, getOverloads, getVirtualFunctions, getVirtualMethods, getUnitTests, getAttributes and finally getAliasThis. Previously an AliasSeq was necessary in order to alias their return. Now the grammar allows to write shorter declarations:

    struct Foo
    {
        static int a;
    }
    
    alias oldWay = AliasSeq!(__traits(getMember, Foo, "a"))[0];
    alias newWay = __traits(getMember, Foo, "a");
    

    To permit this it was more interesting to include __trait in the basic types rather than just changing the alias syntax. So additionally, wherever a type appears a __trait can be used, for example in a variable declaration:

    struct Foo { static struct Bar {} }
    const(__traits(getMember, Foo, "Bar")) fooBar;
    static assert(is(typeof(fooBar) == const(Foo.Bar)));
    
  2. Added -check switch to turn on and off each category of runtime checks.

    Option("check=[assert|bounds|in|invariant|out|switch][=[on|off]]", `Overrides default, -boundscheck, -release and -unittest options to enable or disable specific checks.

    • assert: assertion checking
    • bounds: array bounds
    • in: in contracts
    • invariant: class/struct invariants
    • out: out contracts
    • switch: switch default
    • on or not specified: specified check is enabled.
    • off: specified check is disabled.
    ` )

  3. Add -checkaction=D|C|halt compiler switch.

    It covers action taken when an assert fails, a bounds check fails, or a final switch error happens. D means the usual D behavior of throwing an Error, C means call the C runtime library assert failure function, and halt means halt the program execution.

    The halt is the main addition here, it enables very lightweight assert's.

  4. -color and -color=on will now always output colorized console output

    Before this release -color wouldn't output colorized console output if the terminal detection failed. With this release, a new option auto is introduced for -color=<value> which will continue to be the default:

    • auto: enable colorized output if a tty is detected (default)
    • on: always use colored output.
    • off: never use colored output.

    Hence, it is now possible to use -color (a shortcut for -color=on) to force DMD to emit colorized console output. For example, this will now use colorized console output:

    > echo $(echo "test" | dmd -color - 2>&1)
    __stdin.d(2): Error: no identifier for declarator test
    

  5. The code generated by mixin statements can now be saved with -mixin

    This is useful to debug errors in compilation and provides source for debuggers to show when requested.

  6. Deprecate invalid binary literals

    Prior to this release, binary literals without any digits after the prefix 0b were considered valid. This has now been deprecated.

    auto foo = 0b;   // deprecated
    auto bar = 0b_;  // deprecated
    auto baz = 0b0;  // conforming equivalent
    
  7. Deprecated extern(Pascal) linkage

    This linkage is completely unused, being an heritage from a few decades ago. Additionally, it's only supported by DMD and cause mangling ambiguity.

  8. The deprecation phase for fully qualified names that bypassed private imports is finished
    // a.d
    import std.stdio;
    
    // b.d
    import a;
    
    void main()
    {
        std.stdio.writefln("foo");         // deprecation before patch, now errors
    }
    

    In order to compile the example successfully, public needs to be added to the import located in a.d : public import std.stdio; or import std.stdio; needs to be added to b.d.

  9. Templates are now mangled correctly on POSIX

    Before this version, anything including extern(C++) templates was not correctly mangled on OSX, Linux, and FreeBSD, leading to linker errors.

  10. Added __c_wchar_t as a correct mangling type for C's wchar_t

    This allows code interfacing with C++ that uses wchar_t to link correctly. It replaces wchar (Windows) and dchar (Posix) as the memory type for the DRuntime alias wchar_t.

Runtime changes

  1. Added core.stdcpp.array.

    Added core.stdcpp.array, which links against C++ std::array

  2. Add D header file core.sys.darwin.crt_externs for libc/crt_externs.h on Darwin.

    Add D header file core.sys.darwin.crt_externs for libc/crt_externs.h on Darwin.

  3. Added initialize template argument to object.destroy().

    object.destroy() now receives an initialize argument to specify whether to re-initialize the object after destruction.

  4. Added core.stdcpp.string_view.

    Added core.stdcpp.string_view, which links against C++ std::string_view

Library changes

  1. Add overload std.random.unpredictableSeed!UIntType

    std.random.unpredictableSeed now has an overloaded version std.random.unpredictableSeed!UIntType that can be used to produce seeds of any unsigned type UIntType.

    import std.random : unpredictableSeed;
    
    auto a = unpredictableSeed!uint;
    static assert(is(typeof(a) == uint));
    
    auto b = unpredictableSeed!ulong;
    static assert(is(typeof(b) == ulong));
    
    // The old syntax still works.
    uint c = unpredictableSeed;
    

    Additionally the implementation quality of unpredictableSeed has been improved, speeding it up and eliminating an obvious pattern in the high bit. (Bear in mind that unpredictableSeed is still not cryptographically secure.)

Dub changes

  1. Add Command

    The add command adds a dependency to the dub.json/dub.sdl recipe file.

    Running dub add vibe-d queries the latest version for vibe-d from the registry, then rewrites your recipe file with the new dependency added.

    dub.json:

      "dependencies": {
          "vibe-d": "~>X.Y.Z"
      }
    

    dub.sdl:

    dependency "vibe-d" version="~>X.Y.Z"
    

    It is also possible to add multiple packages at once and explicitly add a simple version specification for some of them.

    For example the command dub add vibe-d='~>0.8.2' mir-algorithm=3.1.21 would add the given 2 dependencies to the recipe file without querying the registry.

    Packages with and without version-specifier can be mixed in a single invocation.

    The can also be used to overwrite existing dependencies of the same name with different version specifications.

  2. dub now supports $DUB variable

    With this release, one can call dub from build commands in the following way:

        // dub.sdl:
        preBuildCommands "$DUB run --single somebuildscript.d"
    

    This is useful if dub is not in the $PATH, or if several versions of dub are installed.

    $DUB is also accessible as environment variable in the build commands processes.

    $DUB points to the running executable, unless it is used as a library. In such case, $DUB will resolve to the first dub executable found in $PATH.

  3. Pre/Post run commands added

    DUB now supports commands preRunCommands which are executed before the target run and postRunCommands which are executed after the target run. Environment variable DUB_TARGET_EXIT_STATUS contains the target executable call status and is available in postRunCommands.

  4. Shebang without .d extension

    Dub single-file packages e.g. app.d can now be called without .d extension. In addition to dub app.d --param you can call dub app --param.

    Also files without .d extension are supported now as single-file packages.

  5. Sort JSON

    JSON files are now sorted before being written to dub.json. This is to prevent the order of the JSON properties from changing when dub.json is updated.

  6. Added experimental feature to improve build cache efficiency

    Using version identifiers to configure certain features can often lead to unnecessary rebuilds of dependencies that don't use those version identifiers. In order to improve the build cache efficiency, dub gained a new experimental --filter-versions switch.

    When --filter-versions is passed to any build, test, or generate command, dub will grep for all the version identifiers packages actually use and only apply those during building. This allows for example to reuse a cached build for a library between two applications using different version identifiers when the library isn't using any of those itself.

    The following regular expressions used to grep for version identifiers.

    enum verRE = ctRegex!`(?:^|\s)version\s*\(\s*([^\s]*?)\s*\)`;
    enum debVerRE = ctRegex!`(?:^|\s)debug\s*\(\s*([^\s]*?)\s*\)`;
    

    For packages that use version identifiers in mixins or auto-generated sources, the list of applicable version identifiers can be specified explicitly in the package file.

    dub.json:

    "-versionFilters": ["Have_vibe_d"]
    "-versionFilters-posix": ["UseUnixSockets", "UseMMap"]
    "-debugVersionFilters": ["ValidateRequests"]
    

    dub.sdl:

    x:versionFilters "Have_vibe_d"
    x:versionFilters "UseUnixSockets" "UseMMap" platform="posix"
    x:debugVersionFilters "ValidateRequests"
    

    Note that the inferred version identifiers are cached and grepping is generally very fast, so explicitly specifying version identifiers should only be used if necessary.

    Also note that specifying either of versionFilters or debugVersionFilters will disable inference for both of them.

    The reservered version identifier none can be used for packages that don't use any version identifiers or debug version identifiers at all.

    dub.json:

    "-versionFilters": ["none"]
    

    dub.sdl:

    x:debugVersionFilters "none"
    

List of all bug fixes and enhancements in D 2.084.0:

DMD Compiler regressions

  1. Bugzilla 15206: [REG2.077] ICE on optimized build, tym = x1d Internal error: backend\cgxmm.c 547
  2. Bugzilla 16284: [REG2.067] CTFE internal error: bad compare
  3. Bugzilla 18938: Dmd segfault when compiling this dub package in test release
  4. Bugzilla 19103: Can imports symbols in module to a struct with mixin.
  5. Bugzilla 19202: deprecated eponymous template prints no warning
  6. Bugzilla 19227: S.init is S.init failing for struct with float member
  7. Bugzilla 19389: Multiple assignment does not work for struct members
  8. Bugzilla 19409: static if (__traits(compiles, __traits(identifier, ...))) evaluates to false even though the expression alone evaluates to true
  9. Bugzilla 19447: [REG2.066] fixed size slice assignment in ctfe loses connection with array
  10. Bugzilla 19473: DMD Segfault on circular struct reference
  11. Bugzilla 19491: ICE (segfault) when initializing scope variable with shared type
  12. Bugzilla 19510: [2.084 REG] random and spurious error about a missing NOLOGO.d file

DMD Compiler bugs

  1. Bugzilla 5973: alias this is not considered with superclass lookup
  2. Bugzilla 6777: alias this disables casting for classes
  3. Bugzilla 9274: is + alias this = wrong code
  4. Bugzilla 10692: Deprecation isn't checked using alias this
  5. Bugzilla 11499: is-expression misbehaving with 'alias this'
  6. Bugzilla 13392: class + alias this + cast(void*) == overzealous cast
  7. Bugzilla 13953: AA .remove pseudo-method doesn't work via alias this
  8. Bugzilla 14632: Diagnostic improvement for invalid cast with alias this
  9. Bugzilla 15876: various cases of SEGFAULT when formatting parser errors
  10. Bugzilla 16082: Can't access alias this member with same name as module
  11. Bugzilla 16086: Imported function name shadows alias this member
  12. Bugzilla 16479: Missing substitution while mangling C++ template parameter for functions
  13. Bugzilla 16633: Case where an alias this is tried before the object itself
  14. Bugzilla 16976: Implicit conversion from ulong to int in foreach_reverse
  15. Bugzilla 18010: Undefined reference to _d_arraycopy when copying arrays in -betterC
  16. Bugzilla 18456: crt_constructor/crt_destructor segfaults if -lib
  17. Bugzilla 18572: AliasSeq default arguments are broken
  18. Bugzilla 18979: Template constructor bypasses private
  19. Bugzilla 19014: Compiler imports symbols that aren't actually imported.
  20. Bugzilla 19086: Bad stack trace for exceptions
  21. Bugzilla 19307: Variables moved to a closure show nonsense in debugger
  22. Bugzilla 19318: Variables captured from outer functions not visible in debugger
  23. Bugzilla 19319: No line number when std.math is missing for x ^^ y
  24. Bugzilla 19336: [ICE] segfault on invalid code
  25. Bugzilla 19376: Do not generate object file from .di file passed on command line
  26. Bugzilla 19381: capture pointer in nested function should not be called "this"
  27. Bugzilla 19415: return non-copyable struct fails if member function has return attribute
  28. Bugzilla 19464: typeof immutable fields order dependent
  29. Bugzilla 19497: the program crash using dmd with -O, it works fine without optimizations.
  30. Bugzilla 19520: assert(TypeExp is TypeExp): compiles with empty structs

DMD Compiler enhancements

  1. Bugzilla 1870: Reproduce offending lines in error messages for string mixins
  2. Bugzilla 7804: Cannot alias __traits directly
  3. Bugzilla 12790: Compiler should keep mixin file around for debugging purposes
  4. Bugzilla 16165: Show expected number of function arguments on mismatch
  5. Bugzilla 19246: Binary literal 0b_ allowed
  6. Bugzilla 19278: extern(C++, "name") doesn't accept expressions
  7. Bugzilla 19439: Make __traits(getAliasThis) return empty tuple for non-aggregate types

Phobos regressions

  1. Bugzilla 13300: pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'
  2. Bugzilla 18824: [REG 2.080] Tuple's opBinaryRight takes precedence over appending a tuple to an array of tuples
  3. Bugzilla 19133: core.exception.rangeerror@std/file.d(3812):
  4. Bugzilla 19213: goto skips declaration of variable in std.algorithm.iteration.joiner

Phobos bugs

  1. Bugzilla 4957: std.concurrency does not allow to pass Tid in struct fields
  2. Bugzilla 18327: std.random.XorshiftEngine is parameterized by UIntType but only works with uint
  3. Bugzilla 18680: std.random.LinearCongruentialEngine has opEquals but no toHash
  4. Bugzilla 18755: std.typecons.Rebindable breaks @safe-ty
  5. Bugzilla 18778: std.format: Positional arguments do not work as expected with nesting
  6. Bugzilla 18796: std.algorithm.substitute asserts on empty range
  7. Bugzilla 19331: std.regex.internal.ir.SmallFixedArray.toHash is ignored because it's non-const
  8. Bugzilla 19338: std.bitmanip.BitArray.count gives segfault for empy BitArray
  9. Bugzilla 19366: Qualify opCast(bool) as const for findSplit, findSplitBefore and findSplitAfter
  10. Bugzilla 19367: std.net.curl does not understand HTTP/2 status lines
  11. Bugzilla 19456: ParameterIdentifierTuple incorrect for abstract methods with unnamed parameters

Phobos enhancements

  1. Bugzilla 5502: More handy ways to create associative arrays
  2. Bugzilla 9702: std.string.replace for single chars too?
  3. Bugzilla 10930: std.array.replace cannot simple replace an element in array
  4. Bugzilla 18595: std.random: add unpredictableSeedOf!UIntType for non-uint unpredictableSeed
  5. Bugzilla 19197: Replace instances of typeid(T).getHash(..) with hashOf
  6. Bugzilla 19238: no-arg splitter should work on ranges of characters
  7. Bugzilla 19308: Optimize std.string.stripLeft
  8. Bugzilla 19364: Decrease template bloat for string functions
  9. Bugzilla 19396: [betterC] ScopeBuffer can't be used in betterC with inline
  10. Bugzilla 19403: Make std.string.stripLeft on char array @nogc nothrow
  11. Bugzilla 19404: Optimize std.string.stripRight
  12. Bugzilla 19405: Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings
  13. Bugzilla 19429: indexOf("a", "b") should be nothrow/@nogc
  14. Bugzilla 19466: functionLinkage documentation omits some values

Druntime regressions

  1. Bugzilla 19498: undefined identifier rt_loadLibraryW

Druntime bugs

  1. Bugzilla 8872: Missing extended window styles (WS_EX_... enumeration) in windows header
  2. Bugzilla 11168: core.stdc.time.asctime() is incorrectly marked as @trusted
  3. Bugzilla 11174: Both AF_PACKET and SO_BINDTODEVICE undefined
  4. Bugzilla 11294: Object destruction with alias this
  5. Bugzilla 19087: final switch cannot be used in -betterC
  6. Bugzilla 19090: core.internal.hash.bytesHash unit test uses incorrect test vector on BigEndian machines
  7. Bugzilla 19204: hashOf doesn't accept SIMD vectors
  8. Bugzilla 19332: hashOf fails to compile for const struct that has non-const toHash & has all fields bitwise-hashable
  9. Bugzilla 19401: Fix bug in core.internal.traits.hasElaborateDestructor & hasElaborateCopyConstructor for struct with static array alias & for nested structs/unions
  10. Bugzilla 19433: Don't consume --DRT-* options if rt_cmdline_enabled is false

Druntime enhancements

  1. Bugzilla 19214: Support object.destruct() for efficient (and correct!) destruction
  2. Bugzilla 19398: Document meaning of core.atomic.MemoryOrder
  3. Bugzilla 19414: object.__cmp(T[]) on big-endian architectures can use memcmp for unsigned integers of any size
  4. Bugzilla 19416: Make core.exception.onOutOfMemoryError work in betterC
  5. Bugzilla 19421: Make pureMalloc, etc. usable in BetterC
  6. Bugzilla 19423: In core.stdc.errno directly link __errno on OpenBSD & NetBSD
  7. Bugzilla 19424: Add Haiku support to core.stdc.errno
  8. Bugzilla 19468: Improve cyclic dependency error message

dlang.org bugs

  1. Bugzilla 19374: TypeVector undefined in grammar

dlang.org enhancements

  1. Bugzilla 19321: Unions "may not" have fields with destructors

Installer bugs

  1. Bugzilla 19434: "Invalid signature" when using install.sh with no ~/.gnupg

Contributors to this release (53)

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

previous version: 2.083.1 – next version: 2.084.1