Change Log: 2.088.0
Download D 2.088.0
released Sep 01, 2019
Compiler changes
- D1 operator overloads have been deprecated.
- Deprecate allowing a constructor declaration in a static block
- deprecated now applies to alias this as well
- Double initialization of immutable fields inside constructor is now obsolete
- add __traits(getLocation, symbol)
- Suppress the "read-modify-write" error if type is a struct or a class
- Postblit and destructors are no longer called on members of anonymous unions.
Runtime changes
- core.atomic : msync has been removed
- Added overloads for core.atomic.cas which don't discard their result.
- Added core.atomic.atomicExchange.
- Non-POSIX CLOCK enum members have been removed from core.sys.posix.time
- The druntime option callStructDtorsDuringGC has been deprecated.
- core.sys.posix.dlfcn : dladdr, dlvsym, Dl_info have been removed
- core.exception: Remove onHiddenFuncError / HiddenFuncError
- core.exception : setAssertHandler has been removed
- core.thread : Fiber.call(bool) has been removed
- Module core.sys.linux.sys.netinet.tcp has been removed
- core.runtime : Runtime.initialize, Runtime.terminate functions taking ExceptionHandler have been removed
- Added core.stdcpp.string.
- Added core.stdcpp.vector.
Library changes
Installer changes
List of all bug fixes and enhancements in D 2.088.0.
Compiler changes
- D1 operator overloads have been deprecated.
The following D1 operator overloads have been deprecated in favor of opUnary:
- opNeg Replace with opUnary(string op)() if (op == "-")
- opCom Replace with opUnary(string op)() if (op == "~")
- opPostInc Replace with opUnary(string op)() if (op == "++")
- opPostDec Replace with opUnary(string op)() if (op == "--")
- opStar Replace with opUnary(string op)() if (op == "*")
The following D1 operator overloads have been deprecated in favor of opBinary:
- opAdd Replace with opBinary(string op)(...) if (op == "+")
- opSub Replace with opBinary(string op)(...) if (op == "-")
- opMul Replace with opBinary(string op)(...) if (op == "*")
- opDiv Replace with opBinary(string op)(...) if (op == "/")
- opMod Replace with opBinary(string op)(...) if (op == "%")
- opAnd Replace with opBinary(string op)(...) if (op == "&")
- opXor Replace with opBinary(string op)(...) if (op == "^")
- opOr Replace with opBinary(string op)(...) if (op == "|")
- opShl Replace with opBinary(string op)(...) if (op == "<<")
- opShr Replace with opBinary(string op)(...) if (op == ">>")
- opUShr Replace with opBinary(string op)(...) if (op == ">>>")
- opCat Replace with opBinary(string op)(...) if (op == "~")
- opIn Replace with opBinary(string op)(...) if (op == "in")
The following D1 operator overloads have been deprecated in favor of opBinaryRight:
- opAdd_r Replace with opBinaryRight(string op)(...) if (op == "+")
- opSub_r Replace with opBinaryRight(string op)(...) if (op == "-")
- opMul_r Replace with opBinaryRight(string op)(...) if (op == "*")
- opDiv_r Replace with opBinaryRight(string op)(...) if (op == "/")
- opMod_r Replace with opBinaryRight(string op)(...) if (op == "%")
- opAnd_r Replace with opBinaryRight(string op)(...) if (op == "&")
- opXor_r Replace with opBinaryRight(string op)(...) if (op == "^")
- opOr_r Replace with opBinaryRight(string op)(...) if (op == "|")
- opShl_r Replace with opBinaryRight(string op)(...) if (op == "<<")
- opShr_r Replace with opBinaryRight(string op)(...) if (op == ">>")
- opUShr_r Replace with opBinaryRight(string op)(...) if (op == ">>>")
- opCat_r Replace with opBinaryRight(string op)(...) if (op == "~")
- opIn_r Replace with opBinaryRight(string op)(...) if (op == "in")
The following D1 operator overloads have been deprecated in favor of opOpAssign:
- opAddAssign Replace with opOpAssign(string op)(...) if (op == "+")
- opSubAssign Replace with opOpAssign(string op)(...) if (op == "-")
- opMulAssign Replace with opOpAssign(string op)(...) if (op == "*")
- opDivAssign Replace with opOpAssign(string op)(...) if (op == "/")
- opModAssign Replace with opOpAssign(string op)(...) if (op == "%")
- opAndAssign Replace with opOpAssign(string op)(...) if (op == "&")
- opOrAssign Replace with opOpAssign(string op)(...) if (op == "|")
- opXorAssign Replace with opOpAssign(string op)(...) if (op == "^")
- opShlAssign Replace with opOpAssign(string op)(...) if (op == "<<")
- opShrAssign Replace with opOpAssign(string op)(...) if (op == ">>")
- opUShrAssign Replace with opOpAssign(string op)(...) if (op == ">>>")
- opCatAssign Replace with opOpAssign(string op)(...) if (op == "~")
Starting with this release, any D code that triggers a lowering to the D1 operator overloads will emit a deprecation warning.
Example of deprecation warning:
struct S { int opAdd(int i) { ... } } void main() { S s; int i; i = s + 1; // Deprecation: `opAdd` is deprecated. Use `opBinary` instead. }
Example of corrective action:
struct S { int opBinary(string op)(int i) if (op == "+") { ... } } void main() { S s; int i; i = s + 1; // OK }
- Deprecate allowing a constructor declaration in a static block
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 does 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.
Beginning with this release, whenever a constructor is encountered in a static context an error message is emitted 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()).
- deprecated now applies to alias this as well
Before this release, deprecated on alias this was accepted by the parser but did not trigger a deprecation mesage on usage.
- Double initialization of immutable fields inside constructor is now obsolete
Inside a constructor scope, assigning to aggregate declaration (class/struct) members is done by considering the first assignment as initialization and subsequent assignments as modifications of the initially constructed object. For const/immutable fields the initialization is accepted in the constructor, but subsequent modifications are not. Example:
class A { int a; immutable int b; this(int a, int b) { this.a = a; this.b = b; this.a = 7; // OK, a is mutable this.b = 9; // Error: immutable field b initialized multiple times } }
However, Bugzilla 18719 shows that this rule does not apply when inside a constructor scope there is a call to a different constructor:
class A { immutable int a; this() { this(42); this.a = 5; // second initialization of immutable field } this(int a) { this.a = a; } }
The above code wrongfully compiled succesfully before this patch, accepting the double initialization of the immutable field a. Starting with this release, this.a = 5 will emit an error stating that a is initialized multiple times.
- add __traits(getLocation, symbol)
Takes one argument which is a symbol. Returns a tuple(string, int, int) whose entries correspond to the filename, line number and column number where the argument was declared.
To disambiguate between overloads, pass the result of getOverloads with the desired index, to getLocation:
module m; int foo(); int foo(int); enum loc = __traits(getLocation, __traits(getOverloads, m, "foo")[0]);
- Suppress the "read-modify-write" error if type is a struct or a class
If a struct or class with shared type implements the opUnary or opOpAssign operator then it is possible to perform "read-modify-write" operations because the operator's implementation is supposed to perform atomic operations.
The purpose of this modification is to allow the creation of wrappers (with structs or classes) to run atomic operations silently, for example:
shared struct Atomic { int a; int opUnary(string s)() if (s == "++") { import core.atomic : atomicOp; return atomicOp!"+="(a, 1); } } Atomic atomicvar; atomicvar++; // Safe! Atomic struct implements opUnary
- Postblit and destructors are no longer called on members of anonymous unions.
Due to a bug in dmd, members of anonymous unions inside struct declarations had their postblits/destructors called when an object of the containing struct type was copied/destroyed. With this release, the postblit/destructor is no longer called in such situations.
Fixes: https://issues.dlang.org/show_bug.cgi?id=19122
Runtime changes
- core.atomic : msync has been removed
It had been deprecated in 2.061 in favor of MemoryOrder.
- Added overloads for core.atomic.cas which don't discard their result.
Existing core.atomic.cas functions discard the result, which make it impossible to implement certain operations. A new set of overloads was added which take ifThis by pointer and write the result back to the argument.
- Added core.atomic.atomicExchange.
Added missing core.atomic.atomicExchange function to the atomic suite.
- Non-POSIX CLOCK enum members have been removed from core.sys.posix.time
Namely CLOCK_MONOTONIC_RAW, CLOCK_MONOTONIC_COARSE (linux), CLOCK_MONOTONIC_PRECISE, CLOCK_MONOTONIC_FAST (FreeBSD, DragonflyBSD), and CLOCK_MONOTONIC_COARSE (CRuntime_Glibc). Those were deprecated in 2.067. They are available on their respective platform modules.
- The druntime option callStructDtorsDuringGC has been deprecated.
Starting with this release utilizing the callStructDtorsDuringGC runtime option will result in a deprecation message printed to stderr. The option will be removed in a future release.
- core.sys.posix.dlfcn : dladdr, dlvsym, Dl_info have been removed
They are linux extensions, not POSIX, and thus can be found in core.sys.linux.dlfcn. They had been deprecated since 2.063.
Those have been deprecated since 2.068, and are related to a language feature that is long gone.
- core.exception : setAssertHandler has been removed
It had been deprecated in 2.064 in favor of assertHandler.
- core.thread : Fiber.call(bool) has been removed
This had been deprecated since 2.068 in favor of Fiber.call(Rethrow.[Yes|No]).
- Module core.sys.linux.sys.netinet.tcp has been removed
This module had been deprecated since 2.077.0. core.sys.linux.netinet.tcp should be imported instead.
- core.runtime : Runtime.initialize, Runtime.terminate functions taking ExceptionHandler have been removed
They were deprecated since 2.065 in favor of rt_init C functions, which allow to initialize the runtime from C code.
- Added core.stdcpp.string.
Added core.stdcpp.string, which links against C++ std::basic_string
Known issues:
Currently, the GCC (libstdc++) implementation has a known issue with the modern __cxx11 ABI, because the C++ struct contains an interior pointer which is illegal in D, and incompatible with D move semantics. To use core.stdcpp.string on linux/GCC, you must use the old string ABI by supplying -D_GLIBCXX_USE_CXX11_ABI=0 to g++, and also -version=_GLIBCXX_USE_CXX98_ABI to your D compiler. Work to define D move constructors is ongoing and expected to resolve this issue when it arrives.
- Added core.stdcpp.vector.
Added core.stdcpp.vector, which links against C++ std::vector
Library changes
- std.array.Appender and RefAppender: use .opSlice() instead of data()
Previonsly, Appender.data() was used to extract a slice of the Appender's array. Now use the [] slice operator instead. The same goes for RefAppender.
- ErrnoException.errno is now nothrow pure @nogc @safe
Before, it was just @system. As it turns out, all it does is return the value of an integer field, so it can have all these attributes.
- Nullable alias get this has been deprecated
Nullable's feature of implicitly converting to its contained value has been marked deprecated.
All sites where a Nullable!T is implicitly converted to T, potentially throwing an error at runtime, will now produce a deprecation warning or error with -de.
To fix this, explicitly use .get to access the contained value of the Nullable.
alias get this is the only implicit conversion in D that may throw an error. Since it is an implicit conversion, it can easily be used accidentally and lead to unexpected runtime errors. By explicitly invoking get, the developer acknowledges that the operation has a chance of error. Conversely, by not implicitly converting Nullable!T to T, the compiler gives the developer a chance to spot forgotten isNull checks.
This feature will be removed after release 2.096.
- Added the std.file.getAvailableDiskSpace functionality.
std.file.getAvailableDiskSpace receives as a parameter the path of a file or directory in the file system, and returns the available disk space on the mounted filesystem. If the given path is nonexistent, an exception is thrown.
import std.file; ulong size = getAvailableDiskSpace("."); assert(size > 0);
import std.file; assertThrown(getAvailableDiskSpace("NonExistentFile"));
- Allow std.json to overlook trailing comma
The JSON grammar does not allow trailing commas, however they are accepted by many JSON parsers. std.json now ignores trailing commas as well. Use JSONOptions.strictParsing to disable this behavior.
import std.json; import std.exception : assertThrown, assertNotThrown; // before assertThrown(parseJSON(`{ "a" : { } , }`)); // after assertNotThrown(parseJSON(`{ "a" : { } , }`));
Installer changes
- Bundled libcurl is now built with DONT_USE_RECV_BEFORE_SEND_WORKAROUND
The bundled libcurl is now build with DONT_USE_RECV_BEFORE_SEND_WORKAROUND. See #399 for details.
Dub changes
- Support for dub global settings file at the root package level
Dub settings file can now also be added to project root folder and has the highest priority.
List of all bug fixes and enhancements in D 2.088.0:
DMD Compiler regressions
- Bugzilla 20021: static if doesn't evaluate opCast(T : bool)
- Bugzilla 20057: compiler hang on conflicting local and imported template
- Bugzilla 20136: opEquals not recognized for AA key
DMD Compiler bugs
- Bugzilla 1142: .stringof performs semantic analysis
- Bugzilla 7443: Better diagnostic on wrongly written static constructor
- Bugzilla 9884: Refused initialization of const array in the module static this()
- Bugzilla 15795: bogus "conflicts with" error depending on order of declaration
- Bugzilla 15818: Multiple function declarations without definition cause ambiguity overloading error
- Bugzilla 18719: Doubly-called constructor against member when using forwarding constructors
- Bugzilla 18729: dmd -run executes in different environment
- Bugzilla 19122: Postblits and destructors called on members of anonymous unions
- Bugzilla 19315: #line inside token string affect outside code
- Bugzilla 19534: Wrong error message "only one index allowed to index int"
- Bugzilla 19646: Initialization of globals not checked for @safe
- Bugzilla 19919: Incorrect initialization of union when first member isn't marked = void
- Bugzilla 19925: static opDispatch not considered in WithStatement
- Bugzilla 19931: Missing error message when defining postblit, rvalue constructor and copy constructor
- Bugzilla 19968: @safe code can create invalid bools resulting in memory corruption
- Bugzilla 20001: Error: a struct is not a valid initializer for a _error_
- Bugzilla 20033: alias this does not support deprecated attribute
- Bugzilla 20047: call of static nested function ignores purity
- Bugzilla 20050: pure function should be able to return function pointer to impure static nested function
- Bugzilla 20073: Wrong implicit conversion for return type
- Bugzilla 20074: header file generation doesn't include attributes with CallExp
- Bugzilla 20096: error message 'cannot goto into try block' is followed by seg fault
- Bugzilla 20100: Segfault with checkaction=context on struct comparison
- Bugzilla 20108: -dip1000 defeated by auto
- Bugzilla 20113: Cannot find source code for runtime library file 'object.d' when the path contains '~'
DMD Compiler enhancements
- Bugzilla 1252: Inline assembler could support BasicType properties
- Bugzilla 18665: Deprecate Undocumented Operator Overloads
- Bugzilla 19917: unions should require that all members are = void initialised
- Bugzilla 19969: Unhelpful error when attempting (incorrectly) to append to a string
- Bugzilla 20000: Casting to interfaces disallowed in @safe code
- Bugzilla 20024: "No property x for type Y" error not as helpful as it should be
- Bugzilla 20037: Imports in module info should be deduplicated
- Bugzilla 20053: add mixin types
- Bugzilla 20059: mismatched function return type inference should give location of inferred type
Phobos bugs
- Bugzilla 19823: std.algorithm.iteration.filter's popFront doesn't always pop the first element like it's supposed to
- Bugzilla 19980: File.byLine skips first line in some cases when used inside map!()
- Bugzilla 19986: Can't assign large const T to std.Variant.VariantN
- Bugzilla 19987: std.variantN wastes space
- Bugzilla 20064: format separator fails with leading zeros
- Bugzilla 20097: SysTime cannot be used with std.concurrency.send
- Bugzilla 20129: AA require with File values gives "Error: return expression expected" in object.d
Phobos enhancements
- Bugzilla 16487: Add function to obtain the available disk space
- Bugzilla 19834: File exception for [std.file.copy] on windows shows the target file rather than the source file
- Bugzilla 19979: std.regex should return null instead of zero-length slice for non-matched captures
- Bugzilla 19983: Add fast path using slice assignment to std.internal.cstring.tempCString
- Bugzilla 19994: Can't nest self-referential Algebraic types
- Bugzilla 20069: std.format digit grouping separator (aka thousands separator) needs to be revisited
- Bugzilla 20098: Improve result of printing std.regex compiled pattern
Druntime bugs
- Bugzilla 20066: Assertion on void[] does not compile with -checkaction=context
- Bugzilla 20088: void[] cast unusable in betterC due to new __ArrayCast template
Druntime enhancements
- Bugzilla 19976: Simplify std.internal.convert.toUbyte CTFE path for float and double
- Bugzilla 20104: core.atomic has no exchange function
- Bugzilla 20122: core.atomic.cas discards result on failure
dlang.org bugs
- Bugzilla 19402: specs for promotion rule of shift exp is wrong
- Bugzilla 19944: Some examples on std.file docs page raise FileException
Contributors to this release (58)
A huge thanks goes to all the awesome people who made this release possible.
- aG0aep6G
- Alexibu
- Andrei Alexandrescu
- Atila Neves
- Basile Burg
- Basile-z
- Bastiaan Veelo
- Boris Carvajal
- Brian Kessler
- Cameron Ross
- Charles McAnany
- Chloé Kekoa
- Dan Printzell
- David Gileadi
- dkorpel
- Dmitry Olshansky
- Dragos Carp
- Eduard Staniloiu
- Elias Batek
- Ernesto Castellotti
- Francesco Mecca
- godmyoh
- Greg V
- Hiroki Noda
- Iain Buclaw
- Jason Schroeder
- jercaianu
- John Colvin
- Jonathan Marler
- Kriyszig
- lenoil98
- Les De Ridder
- Manu Evans
- Marco de Wild
- Martin Kinkelin
- Martin Nowak
- Mathias Lang
- Mathis Beer
- Mike Franklin
- Nathan Sashihara
- Nicholas Wilson
- Paul Backus
- Petar Kirov
- Quirin F. Schroll
- Rainer Schuetze
- Razvan Nitu
- Robert burner Schadek
- Robert Schadek
- Sebastiaan Koppe
- Sebastian Wilzbach
- shove
- Stanislav Blinov
- TJesionowski
- Tomáš Chaloupka
- Viktor
- Vladimir Panteleev
- Walter Bright
- سليمان السهمي (Suleyman Sahmi)