Change Log: 2.084.0
Download D 2.084.0
released Jan 01, 2019
Compiler changes
- Aliases can be created directly from a __trait.
- Added -check switch to turn on and off each category of runtime checks.
- Add -checkaction=D|C|halt compiler switch.
- -color and -color=on will now always output colorized console output
- The code generated by mixin statements can now be saved with -mixin
- Deprecate invalid binary literals
- Deprecated extern(Pascal) linkage
- The deprecation phase for fully qualified names that bypassed private imports is finished
- Templates are now mangled correctly on POSIX
- Added __c_wchar_t as a correct mangling type for C's wchar_t
Runtime changes
Library changes
Dub changes
List of all bug fixes and enhancements in D 2.084.0.
Compiler changes
- 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)));
- 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.
- 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.
- -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
- 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.
- 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
- 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.
- 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.
- 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.
- 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
- Added core.stdcpp.array.
Added core.stdcpp.array, which links against C++ std::array
- 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.
- Added initialize template argument to object.destroy().
object.destroy() now receives an initialize argument to specify whether to re-initialize the object after destruction.
- Added core.stdcpp.string_view.
Added core.stdcpp.string_view, which links against C++ std::string_view
Library changes
- 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
- 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.
- 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.
- 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.
- 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.
- 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.
- 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
- Bugzilla 15206: [REG2.077] ICE on optimized build, tym = x1d Internal error: backend\cgxmm.c 547
- Bugzilla 16284: [REG2.067] CTFE internal error: bad compare
- Bugzilla 18938: Dmd segfault when compiling this dub package in test release
- Bugzilla 19103: Can imports symbols in module to a struct with mixin.
- Bugzilla 19202: deprecated eponymous template prints no warning
- Bugzilla 19227: S.init is S.init failing for struct with float member
- Bugzilla 19389: Multiple assignment does not work for struct members
- Bugzilla 19409: static if (__traits(compiles, __traits(identifier, ...))) evaluates to false even though the expression alone evaluates to true
- Bugzilla 19447: [REG2.066] fixed size slice assignment in ctfe loses connection with array
- Bugzilla 19473: DMD Segfault on circular struct reference
- Bugzilla 19491: ICE (segfault) when initializing scope variable with shared type
- Bugzilla 19510: [2.084 REG] random and spurious error about a missing NOLOGO.d file
DMD Compiler bugs
- Bugzilla 5973: alias this is not considered with superclass lookup
- Bugzilla 6777: alias this disables casting for classes
- Bugzilla 9274: is + alias this = wrong code
- Bugzilla 10692: Deprecation isn't checked using alias this
- Bugzilla 11499: is-expression misbehaving with 'alias this'
- Bugzilla 13392: class + alias this + cast(void*) == overzealous cast
- Bugzilla 13953: AA .remove pseudo-method doesn't work via alias this
- Bugzilla 14632: Diagnostic improvement for invalid cast with alias this
- Bugzilla 15876: various cases of SEGFAULT when formatting parser errors
- Bugzilla 16082: Can't access alias this member with same name as module
- Bugzilla 16086: Imported function name shadows alias this member
- Bugzilla 16479: Missing substitution while mangling C++ template parameter for functions
- Bugzilla 16633: Case where an alias this is tried before the object itself
- Bugzilla 16976: Implicit conversion from ulong to int in foreach_reverse
- Bugzilla 18010: Undefined reference to _d_arraycopy when copying arrays in -betterC
- Bugzilla 18456: crt_constructor/crt_destructor segfaults if -lib
- Bugzilla 18572: AliasSeq default arguments are broken
- Bugzilla 18979: Template constructor bypasses private
- Bugzilla 19014: Compiler imports symbols that aren't actually imported.
- Bugzilla 19086: Bad stack trace for exceptions
- Bugzilla 19307: Variables moved to a closure show nonsense in debugger
- Bugzilla 19318: Variables captured from outer functions not visible in debugger
- Bugzilla 19319: No line number when std.math is missing for x ^^ y
- Bugzilla 19336: [ICE] segfault on invalid code
- Bugzilla 19376: Do not generate object file from .di file passed on command line
- Bugzilla 19381: capture pointer in nested function should not be called "this"
- Bugzilla 19415: return non-copyable struct fails if member function has return attribute
- Bugzilla 19464: typeof immutable fields order dependent
- Bugzilla 19497: the program crash using dmd with -O, it works fine without optimizations.
- Bugzilla 19520: assert(TypeExp is TypeExp): compiles with empty structs
DMD Compiler enhancements
- Bugzilla 1870: Reproduce offending lines in error messages for string mixins
- Bugzilla 7804: Cannot alias __traits directly
- Bugzilla 12790: Compiler should keep mixin file around for debugging purposes
- Bugzilla 16165: Show expected number of function arguments on mismatch
- Bugzilla 19246: Binary literal 0b_ allowed
- Bugzilla 19278: extern(C++, "name") doesn't accept expressions
- Bugzilla 19439: Make __traits(getAliasThis) return empty tuple for non-aggregate types
Phobos regressions
- Bugzilla 13300: pure function 'std.array.Appender!(T[]).Appender.ensureAddable' cannot call impure function 'test.T.__fieldPostBlit'
- Bugzilla 18824: [REG 2.080] Tuple's opBinaryRight takes precedence over appending a tuple to an array of tuples
- Bugzilla 19133: core.exception.rangeerror@std/file.d(3812):
- Bugzilla 19213: goto skips declaration of variable in std.algorithm.iteration.joiner
Phobos bugs
- Bugzilla 4957: std.concurrency does not allow to pass Tid in struct fields
- Bugzilla 18327: std.random.XorshiftEngine is parameterized by UIntType but only works with uint
- Bugzilla 18680: std.random.LinearCongruentialEngine has opEquals but no toHash
- Bugzilla 18755: std.typecons.Rebindable breaks @safe-ty
- Bugzilla 18778: std.format: Positional arguments do not work as expected with nesting
- Bugzilla 18796: std.algorithm.substitute asserts on empty range
- Bugzilla 19331: std.regex.internal.ir.SmallFixedArray.toHash is ignored because it's non-const
- Bugzilla 19338: std.bitmanip.BitArray.count gives segfault for empy BitArray
- Bugzilla 19366: Qualify opCast(bool) as const for findSplit, findSplitBefore and findSplitAfter
- Bugzilla 19367: std.net.curl does not understand HTTP/2 status lines
- Bugzilla 19456: ParameterIdentifierTuple incorrect for abstract methods with unnamed parameters
Phobos enhancements
- Bugzilla 5502: More handy ways to create associative arrays
- Bugzilla 9702: std.string.replace for single chars too?
- Bugzilla 10930: std.array.replace cannot simple replace an element in array
- Bugzilla 18595: std.random: add unpredictableSeedOf!UIntType for non-uint unpredictableSeed
- Bugzilla 19197: Replace instances of typeid(T).getHash(..) with hashOf
- Bugzilla 19238: no-arg splitter should work on ranges of characters
- Bugzilla 19308: Optimize std.string.stripLeft
- Bugzilla 19364: Decrease template bloat for string functions
- Bugzilla 19396: [betterC] ScopeBuffer can't be used in betterC with inline
- Bugzilla 19403: Make std.string.stripLeft on char array @nogc nothrow
- Bugzilla 19404: Optimize std.string.stripRight
- Bugzilla 19405: Speed up backwards UTF-8 decoding in stripRight & make nogc nothrow for strings
- Bugzilla 19429: indexOf("a", "b") should be nothrow/@nogc
- Bugzilla 19466: functionLinkage documentation omits some values
Druntime regressions
- Bugzilla 19498: undefined identifier rt_loadLibraryW
Druntime bugs
- Bugzilla 8872: Missing extended window styles (WS_EX_... enumeration) in windows header
- Bugzilla 11168: core.stdc.time.asctime() is incorrectly marked as @trusted
- Bugzilla 11174: Both AF_PACKET and SO_BINDTODEVICE undefined
- Bugzilla 11294: Object destruction with alias this
- Bugzilla 19087: final switch cannot be used in -betterC
- Bugzilla 19090: core.internal.hash.bytesHash unit test uses incorrect test vector on BigEndian machines
- Bugzilla 19204: hashOf doesn't accept SIMD vectors
- Bugzilla 19332: hashOf fails to compile for const struct that has non-const toHash & has all fields bitwise-hashable
- Bugzilla 19401: Fix bug in core.internal.traits.hasElaborateDestructor & hasElaborateCopyConstructor for struct with static array alias & for nested structs/unions
- Bugzilla 19433: Don't consume --DRT-* options if rt_cmdline_enabled is false
Druntime enhancements
- Bugzilla 19214: Support object.destruct() for efficient (and correct!) destruction
- Bugzilla 19398: Document meaning of core.atomic.MemoryOrder
- Bugzilla 19414: object.__cmp(T[]) on big-endian architectures can use memcmp for unsigned integers of any size
- Bugzilla 19416: Make core.exception.onOutOfMemoryError work in betterC
- Bugzilla 19421: Make pureMalloc, etc. usable in BetterC
- Bugzilla 19423: In core.stdc.errno directly link __errno on OpenBSD & NetBSD
- Bugzilla 19424: Add Haiku support to core.stdc.errno
- Bugzilla 19468: Improve cyclic dependency error message
dlang.org bugs
- Bugzilla 19374: TypeVector undefined in grammar
dlang.org enhancements
- Bugzilla 19321: Unions "may not" have fields with destructors
Installer bugs
- 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.
- aG0aep6G
- Andrei Alexandrescu
- Andu033
- ARaspiK
- Arun Chandrasekaran
- Basile Burg
- BBasile
- Chris
- David Gileadi
- Diederik de Groot
- dukc
- Eduard Staniloiu
- H. S. Teoh
- HANATANI Takuma
- Iain Buclaw
- Jacob Carlborg
- jmh530
- Joakim Noah
- Johan Engelen
- Johannes Pfau
- jsatellite
- kinke
- Laurent Tréguier
- look-at-me
- Manu Evans
- Martin Nowak
- Mathias Lang
- Mathis Beer
- Mike Franklin
- Mike Parker
- Nathan Sashihara
- Nicholas Lindsay Wilson
- Nicholas Wilson
- Nick Treleaven
- Oleksandr Palamar
- Paul Backus
- Per Nordlöw
- Petar Kirov
- Pharap
- Rainer Schuetze
- Razvan Nitu
- Richard Palme
- Robert burner Schadek
- Roman Chistokhodov
- rracariu
- Sebastian Wilzbach
- Simen Kjærås
- Stanislav Blinov
- Steven Schveighoffer
- Thomas Mader
- Vladimir Panteleev
- Walter Bright
- wolframw