Change Log: 2.103.0
Download D 2.103.0
released Apr 01, 2023
Compiler changes
Library changes
List of all bug fixes and enhancements in D 2.103.0.
Compiler changes
- Add __check(assign-expression) to ImportC
C code normally relies on #include <assert.h> to add support for assert's. D has them builtin to the language, which is much more convenient and does not rely on a preprocessor. This extension adds
__check(assign-expression)
as an expression to ImportC. The compiler switch -checkaction=C gives it the same behavior as C's assert macro. If the compiler switch -release is thrown, the __check's are ignored. The __check expressions are handy for writing C programs that are free of reliance on #include.
__assert is not used due to conflicts with some C .h files.
- Alias this for classes is deprecated
Using alias this for classes has not been clearly specified and the lookup rules in such circumstances are not defined. As a consequence, various failures or crashes may appear when alias this is used in conjunction with classes. Starting with this release, alias this for classes is being deprecated. As an alternative, getter/setter methods may be used to replace the alias this. This can be generically handled by:
static foreach(member, __traits(allMembers, LeClass)) mixin("ref auto " ~ member() { return $field_name." ~ member ~ "; }");
- -preview=dip25 has been enabled by default
Deprecation warnings for DIP25 violations have been enabled since 2.092. Starting with this release, it will report errors, unless the -revert=dip25 switch is used. Using the switch (or its short version -dip25) is now deprecated.
ref int escapeRef(ref int x) {return x;} // Formerly: // Deprecation: returning `x` escapes a reference to parameter `x` // perhaps annotate the parameter with `return` // // Now it is an error, unless `-revert=dip25` is used
- export int a; now generates dllexport instead of dllimport
In order to make it dllimport, use:
export extern int a;
- Deprecate traits(isVirtualFunction) and traits(getVirtualFunctions)
Up until this release, D had both traits(isVirtualFunction) and traits(isVirtualMethod) (and their coressponding traits(get...) counterpart). The differenrcte between the two is that isVirtualFunction returns true for final methods that do not override anything. This is in contradiction with the D spec which states that final functions that do not override other functions cannot be virtual. isVirtualMethod correctly returns false in that case.
Starting with this release, both traits(isVirtualFunction) and traits(getVirtualFunctions) are deprecated. If the behavior of traits(isVirtualFunction) is desired, it can be achieved by traits(isVirtualMethod, f) || (traits(isFinalFunction, f) && !traits(isOverrideFunction, f)).
Library changes
- Unicode grapheme walking updated to conform to Unicode version 15
Up until now graphemeStride, byGrapheme and decodeGrapheme functions in std.uni have used obsolete rules from earlier Unicode standards.
This release brings grapheme breaking rules up to date with Unicode version 15. This means Phobos functions now recognise extended pictogram sequences and prepend characters.
- Better static assert messages for std.algorithm.iteration.joiner
Up until now filter used a template constraint to check if the passed Data could be used. If it were not, it was very tedious to figure out why.
As the template constraint is not used to overload the symbol template function, the constrains are move into static asserts with expressive error messages.
- Better static assert messages for std.algorithm.sorting.sort
Up until now sort used a template constraint to check if the passed Range could be used. If it were not, it was very tedious to figure out why.
As the template constraint is not used to overload the symbol template function, the constrains are move into static asserts with expressive error messages.
Dub changes
- The --color argument now accepts values auto, never, always
The previous automatic, on, off values are still supported, but undocumented, because they are used in almost no other program like this. For consistency, with other Linux tools especially, we have implemented and switched the defaults to the widely-used auto, never, always values.
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 23688: FTBFS: error: cannot convert 'Expression' to 'Expression*'
- Bugzilla 23710: [REG master] Reachable code inside an 'if (false)' block no longer gets codegen
- 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 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 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 23669: [DIP1000] Compound assignment to length of slice member variable in scope method fails
- Bugzilla 23676: Static foreach hangs compilation for some time
- Bugzilla 23682: dip1000 problem with return by ref
- Bugzilla 23694: compilable/ctests2.c:51:9: error: initializer element is not constant
- 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 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
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 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 (43)
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
- Drehuta Andreea
- Dumitrache Adrian-George
- Hiroki Noda
- Iain Buclaw
- Ikey Doherty
- ioanavivi12
- Jan Jurzitza
- Johan Engelen
- João Lourenço
- KytoDragon
- Luís Ferreira
- Mateiuss
- MathewColin
- Mathias Lang
- 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