Change Log: 2.103.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
Compiler changes
- A missed case of conflicting extern (D) @system function definitions has been deprecated
- Deprecate the ability to call __traits(getAttributes) on overload sets
- Deprecate non-empty for statement Increment clause with no effect
- Array literals assigned to scope array variables can now be allocated on the stack
- static assert now supports multiple message arguments
- -preview=systemVariables has been added
Runtime changes
Library changes
Installer changes
List of all upcoming bug fixes and enhancements in D 2.103.0.
Compiler changes
- A missed case of conflicting extern (D) @system function definitions has been deprecated
Having multiple definitions of functions within a module had been turned into an error in DMD 2.095.0.
However, the compiler would not issue an error when two implementations differed by an explicit and inferred @system attribute, although they have the same mangling.
void foo() {} void foo() @system {} // no error
This bug has been fixed, and DMD will now issue a deprecation if there are such conflicting @system function implementations. Starting from DMD 2.112, it will produce a multiple definition error just like other kinds of conflicting functions within a module.
- Deprecate the ability to call __traits(getAttributes) on overload sets
Up until this release, __traits(getAttributes) could be called both on individual functions and on overload sets. However, in the latter case, the compiler simply collected the user defined attributes for the first lexically defined function. This behavior is error prone. Consider:
module test; @("gigi") void fun() {} @("mimi") void fun(int) {} void main() { static foreach(attr; __traits(getAttributes, fun)) pragma(msg, attr);
The above code will print "gigi" although there is no indication on what overload is actually queried. The first one is always picked.
Starting with this release, this sort of usage of __traits(getAttributes) is deprecated. If a specific overload needs to be handled, __traits(getOverloads) may be used in conjunction with __traits(getAttributes) for proper behavior:
module test; @("gigi") void fun() {} @("mimi") void fun(int) {} void main() { static foreach (t; __traits(getOverloads, test, "fun")) static foreach(attr; __traits(getAttributes, t)) pragma(msg, attr);
The above code prints:
gigi mimi
- Deprecate non-empty for statement Increment clause with no effect
The last clause of a for statement should not produce a value without also having some meaningful side-effect. This is now detected with a deprecation message. The following for statements each trigger the deprecation:
// evaluating `j` has no side-effects int j; for (;; j) {...} // unnecessary dereference for (ubyte* sp;; *sp++) {...} // first clause is a block statement // last clause is a function literal, not a block statement for({j = 2; int d = 3;} j + d < 7; {j++; d++;}) {...}
Note: Calling a function returning void is not deprecated even if the function does nothing. This is for generic code.
- Array literals assigned to scope array variables can now be allocated on the stack
Formerly, they were always allocated with the Garbage Collector, making it unavailable in @nogc or -betterC code. This led to frequent use of the following workaround:
void main() @nogc { int[3] buffer = [10, 20, 30]; int[] arr = buffer[]; }
This can now be written in a single line:
void main() @nogc { scope int[] arr = [10, 20, 30]; }
With the following limitations:
- The variable must be explicitly annotated scope, not just inferred scope
- The -preview=dip1000 must be passed, to prevent introducing memory corruption in legacy code.
- The array literal must be initializing the variable. Subsequent array literals assignments still use the GC.
- The array elements may not have a destructor
Some of these limitations might get lifted in the future.
- static assert now supports multiple message arguments
When the condition evaluates to false, any subsequent expressions will each be converted to string and then concatenated. The resulting string will be printed out along with the error diagnostic.
enum e = 3; static assert(false, "a = ", e);
Will print:
file.d(2): Error: static assert: a = 3
- -preview=systemVariables has been added
Since DIP 1035 - System Variables has been accepted, variables marked @system may no longer be accessed from @safe code. To avoid code breakage, the compiler will start with emitting deprecation warnings. The preview switch will turn these into errors, and it will be enabled by default in a future release.
@system int* p; struct S { @system int i; } void main() @safe { int x = *p; // error with `-preview=systemVariables`, deprecation otherwise S s; s.i = 0; // ditto }
Note that currently this is limited to variables explicitly marked @system, inference of @system based on a variable's initializer is yet to be implemented.
Runtime changes
- The default Throwable.TraceInfo generation now is @nogc.
The way this works:
- The runtime now has 2 trace-related functions, one for allocating a traceinfo, and one for deallocating the traceinfo. Both are set via the same Runtime.traceHandler function. The second parameter that sets the deallocation function is optional (so existing code will not be affected).
- When a Throwable is thrown, if the trace info is not yet set, the runtime uses the designated function to allocate a trace info. If the deallocation function is non-null, the function pointer is copied into the Throwable, into the new member infoDeallocator.
- When the Throwable is destroyed, if the infoDeallocator member is set, it is called on the info member.
The default allocator and deallocator now uses C malloc and free to allocate and deallocate the TraceInfo. Almost everything was already nogc, except for the allocation of the TraceInfo object itself.
The benefits:
- Stack traces can now be generated when run inside the GC collection routine.
- InvalidMemoryOperationError now has a stack trace.
- Little known is that even inside @nogc functions, throwing a Throwable actually was using the GC, that is no longer the case (by default).
- Certain GC hangs have been fixed (see bug fixes listed below).
One possible drawback is that the TraceInfo is deallocated upon Throwable being finalized, leading to a potential dangling pointer situation. If you do copy the info out of the Throwable, makes sure to not keep it beyond the lifetime of the Throwable, or make sure to set the infoDeallocator member to null.
Library changes
- Single- and double-precision implementations for log function families
New float and double overloads of std.math.exponential.log, std.math.exponential.log10, std.math.exponential.log1p, std.math.exponential.log2, and std.math.exponential.logb have been added to Phobos with proper 'software' implementations in the corresponding precision. Furthermore, std.math.exponential.logb is now pure.
While this may result in a slowdown in some cases for DMD, the overall speed-up factor for GDC and LDC is over 3x, for both double and float.
This also implies less precise results, especially in single-precision, so if your code depended on more accurate results via 80-bit intermediate precision, you'll have to cast the argument(s) explicitly now.
- The Unicode property "C" aka "Other" has had the wrong properties associated with it.
If you use unicode.c or unicode.Other (case insensitive) from std.uni, you should mitigate or fix your codebase.
This change makes it match the Unicode Techical Report #44. Unfortunately if you are already using it with its previous wrong values, this will break your code, below is a function which reflects the original values that you can use to mitigate against any breakage.
@property auto loadPropertyOriginal(string name)() pure { import std.uni : unicode; static if (name == "C" || name == "c" || name == "other" || name == "Other") { auto target = unicode.Co; target |= unicode.Lo; target |= unicode.No; target |= unicode.So; target |= unicode.Po; return target; } else return unicode.opDispatch!name; }
- Unicode table generator is now in Phobos, tables are updated to version 15.
It is likely that this change will result in breakage in code and program usage. This is due to a number of factors, the tables being updated so significantly and the table generator not having all its changes commited throughout the years.
- std.typecons.Unique now calls destroy on struct types
When Unique goes out of scope, any destructor will now be called. Previously the destructor was not called then.
static int i; struct S { ~this() { i++; } } { Unique!S u = new S; // S.~this now called here } assert(i == 1);
Note: Above, the struct destructor will also be called by the GC just before the memory for new S is reclaimed. Take care that any struct destructor used will handle being called again on the struct .init value.
Installer changes
- Update the bundled VisualD package
The VisualD package version that the installer downloads hasn't been updated in years. This has been remedied by a version bump to 1.3.1, the latest release of VisualD.
- Prefer 64 bit over 32 bit DMD on Windows 64 bit.
The NSIS installer for Windows has the option "Add to PATH". Previously, only the 32 bit version of DMD was added to the PATH environment variable. Now, on Windows 64 bit, the 64 bit version of DMD will be selected from PATH.
List of all bug fixes and enhancements in D 2.103.0:
DMD Compiler regression fixes
- Bugzilla 15985: [REG2.068/2.069] Code doesn't link unless compiled with -debug
- Bugzilla 18472: [Reg 2.078] betterC: cannot use format at compile time.
- Bugzilla 21772: [REG2.069] Consecutive different-signed double.nans in an array literal take the sign of the previous nan (same for float and real)
- Bugzilla 22039: ICE on infinite recursion in default parameter
- Bugzilla 23674: incompatible types for array comparison: string and string
- Bugzilla 23688: FTBFS: error: cannot convert 'Expression' to 'Expression*'
- Bugzilla 23710: [REG master] Reachable code inside an 'if (false)' block no longer gets codegen
- Bugzilla 23732: Cannot create shared instance of class with -preview=nosharedaccess
- Bugzilla 23745: Segfault with forward reference mismatched override with undeclared type
- Bugzilla 23758: [REG 2.103] Segfault accessing NewExp::argprefix from C++
- Bugzilla 23799: Link error with -betterC
DMD Compiler bug fixes
- Bugzilla 10886: Typeof on @property function triggers 'wrong this' type error
- Bugzilla 11051: Unmatched case in a final switch should throw in both release and non-release mode
- Bugzilla 16098: align(N) not respected for stack variables if N > platform stack alignment
- Bugzilla 16213: CTFE internal error with static array $ as template argument
- Bugzilla 20781: Can call @live function without checking dip1021 rules
- Bugzilla 20908: -preview=nosharedaccess requires zero-initializion for aggregates
- Bugzilla 21288: Wrong context pointer for alias this function
- Bugzilla 21492: betterC: TypeInfo is generated for code guarded by if(__ctfe)
- Bugzilla 21821: Optimizer assumes immutables do not change, but they can in @system code
- Bugzilla 22916: [dip1000] copy of ref return still treated as scope variable
- Bugzilla 23145: Stack allocation of scope new variables defeats @safe
- Bugzilla 23195: Win64 function ABI bug for small non-POD arguments
- Bugzilla 23261: druntime core.std.attribute.Tagged1_2 constructor is unsafe
- Bugzilla 23387: ImportC: identical structs defined in two C files lead to duplicate .init symbol on macOS
- Bugzilla 23407: ImportC: function-local struct definition as part of variable declaration doesn’t shadow global definition
- Bugzilla 23514: Incorrect compilation when adding a 64-bit constant to a link-time address
- Bugzilla 23545: export int a; should generate dllexport, not dllimport
- Bugzilla 23583: ImportC: undefined identifier __builtin___memmove_chk
- Bugzilla 23584: ImportC: __builtin_bit_cast not supported
- Bugzilla 23598: Circular reference bug with static if and eponymous templates
- Bugzilla 23606: betterC with CTFE and gc
- Bugzilla 23616: ImportC: clang __has_feature and __has_extension not recognized
- Bugzilla 23617: traits(child) compile error need this for something that doesn't need this
- Bugzilla 23622: ImportC #defines conflict with declarations
- Bugzilla 23635: Nonsensical "case must be a string or an integral constant, not x"
- Bugzilla 23639: Casting to shared not allowed with -preview=nosharedaccess
- Bugzilla 23648: Replace all sprintf with snprintf
- Bugzilla 23650: Using typeid with struct defined in in __traits(compiles, ...) causes linker error
- Bugzilla 23651: Order dependency in semantic analysis of template members
- Bugzilla 23658: .di generation of variables should turn them into declarations
- Bugzilla 23662: ImportC bad handling of enum arguments for a function
- Bugzilla 23669: [DIP1000] Compound assignment to length of slice member variable in scope method fails
- Bugzilla 23672: importC: Infinite recursion: Error: found 'End of File' when expecting ','
- Bugzilla 23676: Static foreach hangs compilation for some time
- Bugzilla 23679: off-by-one error for static array size limit
- Bugzilla 23682: dip1000 problem with return by ref
- Bugzilla 23694: compilable/ctests2.c:51:9: error: initializer element is not constant
- Bugzilla 23705: dmd: src/dmd/backend/cgcod.d:734: Assertion `sz >= 0' failed.
- Bugzilla 23711: compilable/testcstuff1.c:63:1: error: invalid use of restrict
- Bugzilla 23717: runnable/bitfields.c:192:5: error: unknown type name S; use struct keyword to refer to the type
- Bugzilla 23743: wrong code with foreach, ubyte, >=, ternary operator
- Bugzilla 23752: ImportC: can't take address of dereferenced void pointer
- Bugzilla 23760: Error: unknown
- Bugzilla 23763: ICE on operations involving zero-initialized structs
- Bugzilla 23767: ImportC: ternary with null constant has wrong pointer type
- Bugzilla 23778: Code generator fails to handle __c_complex_real properly for Windows
- Bugzilla 23781: [ICE] Segmentation Fault when taking the address of a ref return at CTFE
- Bugzilla 23783: -preview=nosharedaccess does not detect comparison of shared data
- Bugzilla 23790: Cannot use cas on member variable with -preview=nosharedaccess
- Bugzilla 23792: lexer warns about preprocessor inside token strings
DMD Compiler enhancements
- Bugzilla 11316: Some cases of missing delegate argument type inference
- Bugzilla 13656: clarify error message upon trying to declare a variable of type ref
- Bugzilla 16495: __traits(fullyQualifedName) instead of std.traits.fullyQualifiedName
- Bugzilla 20101: BetterC: Template instantiation in CTFE only context should skip codegen / nogc / ... Phases
- Bugzilla 23558: add __traits(getModuleClasses [, module name])
- Bugzilla 23597: .di files not compatible with -i
Phobos regression fixes
- Bugzilla 23776: getSymbolsByUDA fails to fetch symbols from module
Phobos bug fixes
- Bugzilla 23474: Grapheme should end after carriage return if not followed by line feed.
- Bugzilla 23600: [std.format.read] formattedRead static asserts with Tuple and compile time format string
- Bugzilla 23668: Can't stable sort structs with disabled default constructor.
- Bugzilla 23724: HTTP.onReceive example does not compile
- Bugzilla 23750: log1p for floats/doubles not actually providing extra accuracy
Phobos enhancements
- Bugzilla 19567: [std.stdio] Not really helpful documentation of tell
- Bugzilla 20397: [std.algorithm] documentation nthPermutation
- Bugzilla 23683: std.file.setTimes requests more permissions than needed
- Bugzilla 23706: Do not escape POSIX shell parameters unless necessary
Druntime regression fixes
- Bugzilla 23608: [musl 32-bit] Time functions linked incorrectly on musl >=1.2.0 / 32-bit
Druntime bug fixes
- Bugzilla 19575: core.cpuid not usable without a runtime
- Bugzilla 23625: Function ZeroMemory missing in windows headers
dlang.org bug fixes
- Bugzilla 6583: cast() operation not fully specified
- Bugzilla 11493: dlang.org/type.html incorrectly says that you can't cast from -1 to unsigned types
- Bugzilla 16707: [Templates] run variadic templates example failed
- Bugzilla 21132: Ff two keys in an associative array literal are equal
- Bugzilla 21178: It is not explained what is "unknown"
- Bugzilla 23716: ImportC: Missing documentation on the asm keyword accepted as an extension
dlang.org enhancements
- Bugzilla 18765: [Arrays] Docs need info on initialization of static array with element literal
- Bugzilla 20997: Missing example of scope guard executing after return statement
- Bugzilla 22418: Error in documentation on strings
- Bugzilla 22594: Update "Interfacing to C" to include intptr_t and uintptr_t
- Bugzilla 23612: Template constraints article not listed in article index
- Bugzilla 23636: No spec docs for shared qualifer
- Bugzilla 23730: Clarify IsExpression Identifier : and == TypeCtor spec
Tools bug fixes
- Bugzilla 23624: Race condition in test runner for DMD
- Bugzilla 23634: Possible data race with runnable example tester
Contributors to this release (47)
A huge thanks goes to all the awesome people who made this release possible.
- Amaury
- Andra Maslaev
- Andrea Fontana
- Ate Eskola
- Ben Jones
- BVRazvan
- Daniel Zuncke
- DanutAldea
- Dennis
- Dennis Korpel
- Dmytro Katyukha
- Drehuta Andreea
- Dumitrache Adrian-George
- Hiroki Noda
- Iain Buclaw
- Ikey Doherty
- ioanavivi12
- Jan Jurzitza
- Johan Engelen
- João Lourenço
- KytoDragon
- Luís Ferreira
- Martin Kinkelin
- Mateiuss
- MathewColin
- Mathias Lang
- Mathis Beer
- matthriscu
- Mike Parker
- Nathan Sashihara
- Nick Treleaven
- Paul Backus
- Quirin F. Schroll
- Rareș Constantin
- Razvan Mihai Popa
- Razvan Nitu
- richard (rikki) andrew cattermole
- Robert burner Schadek
- Robert Grancsa
- Robert Stoica
- Rosca Rares
- Steven Schveighoffer
- Teodor Dutu
- Tudor Brindus
- Vladimir Panteleev
- Walter Bright
- Zachary Yedidia