Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Downloads
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Forums
  - IRC
  - Wiki
  - GitHub
  - Issues
  - Get involved
  - Contributors
  - Foundation
  - Donate
  - Sponsors
- Resources
  - Tour
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
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.078.0

Download D 2.078.0
released Jan 01, 2018

#### Compiler changes

1. opDispatch resolution in with statements
2. Generate header files using do instead of body as per DIP1003
3. pragma(crt_constructor) and pragma(crt_destructor) were added
4. Subtraction of pointers that point to different types has been deprecated.
5. Variadic template arguments no longer require alias workaround
6. fix Issue 16997 - Integral promotion rules not being followed for unary + - ~ operators
7. Optional ModuleInfo
8. Added RAII and try-finally support for -betterC mode.
9. Windows: dmd can now detect Visual Studio installation paths

#### Runtime changes

1. core.runtime now allows more fine-grained control over unittests.
2. The runtime learned a few new options to customize how coverage reports are created.

#### Library changes

1. mean Was Added To std.algorithm
2. findSkip can now skip elements using just a predicate function
3. std.array.byPair now returns a NamedTuple
4. std.container.dlist supports linearRemoveElement
5. std.container.slist supports linearRemoveElement
6. Deprecate save for std.range.package.Transposed
7. std.typecons.Ternary.opBinary supports bool bitwise operands

List of all bug fixes and enhancements in D 2.078.0.

#### Compiler changes

1. opDispatch resolution in with statements

   opDispatch resolution in with statements has been modified to bring it into compliance with the existing scope resolution rules in the language specification. See WithStatement in the language specification.

   Prior to this release, the following code would not compile because the compiler would not be able to resolve the second call to f(), as Bar does not implement f() or opDispatch.

       import std.stdio;

       struct Foo
       {
           void opDispatch(string name)()
           {
               mixin("writeln(\"Foo.opDispatch!" ~ name ~ "\");");
           }
       }

       struct Bar
       {
           // `Bar` does not implement `f()` or `opDispatch`
       }

       void main()
       {
           Foo foo;
           Bar bar;

           with(foo)
           {
               f();       // prints "Foo.opDispatch!f"
               with(bar)
               {
                   f();   // Prior to this Release: Error: undefined identifer `f`
                          // Starting with  this release: Prints "Foo.opDispatch!f".
                          // `f`'s resolution is forwarded up the scope hierarchy.
               }
           }
       }

   Starting with this release, the second call to f() will be forwarded up the scope hierarchy, matching the implementation of Foo.opDispatch.

2. Generate header files using do instead of body as per DIP1003

   Support for DIP1003 was added in release 2.075.0. Use of body in an error message and header file generation has been fixed in this release.

3. pragma(crt_constructor) and pragma(crt_destructor) were added

   This allows programs to run initialization code before or cleanup code after C main.

   In particular those pragmas can be used in -betterC code as substitutes for shared static this() and shared static ~this().

   Note: At the time of execution druntime is not initialized.

   Note: The order in which constructors are executed is unspecified.

       import core.stdc.stdio;

       pragma(crt_constructor)
       void init()
       {
           puts("init");
       }

       pragma(crt_destructor)
       void fini()
       {
           puts("fini");
       }

       extern(C) int main()
       {
           puts("main");
       }

4. Subtraction of pointers that point to different types has been deprecated.

   The language specification reads: "If both operands are pointers, and the operator is -, the pointers are subtracted and the result is divided by the size of the type pointed to by the operands. It is an error if the pointers point to different types."

   Prior to this release, the compiler allowed the following pointer arithmetic:

       void* p1;
       int* p2;
       auto p3 = p2 - p1;

   Starting with this release, the subtraction of pointers that point to different types will emit a deprecation warning. The warning will remain in place for at least a year, after which it will be changed to an error.

5. Variadic template arguments no longer require alias workaround

   Prior to this release, the following code would not compile.

       class C(Types...)
       {
           void apply(U)(U delegate(Types[0]) f0) { }  // Error: cannot deduce function from argument types
       }

       void test()
       {
           C!int c;

           int f(int) { return 0; }

           c.apply(&f);
       }

   It could be worked around by aliasing the individual template arguments.

       class C(Types...)
       {
           alias Types[0] T0;
           void apply(U)(U delegate(T0) f0) { }  // OK
       }

   Starting with this release, the workaround is no longer required.

6. fix Issue 16997 - Integral promotion rules not being followed for unary + - ~ operators

   To follow the C integral promotion rules, types are promoted to int before the unary + - or ~ operators are applied. Existing D does not do this.

   This is corrected when one of the following command line switches are used:

   -transition=intpromote -transition=16997

   It affects operands of type byte, ubyte, short, ushort, char, and wchar. The operands are promoted to int before the operator is applied. The result type will now be int.

   The values computed will be different for some values of the operands:

   * All values of - and ~ applied to ubyte, ushort, char, and dchar operands will change.

   * The values of -byte(-128) and -short(-32768) will change.

   If one of the '-transition=' switches is not specified, a deprecation will be emitted for these operations. To fix the deprecation and work as desired with or without the '-transition=' switch:

   Option 1:

   Rewrite op b as op int(b) to use correct, i.e. C-like, behavior.

   Option 2:

   Rewrite op b as typeof(b)(op int(b)) to preserve the old behavior.

   Once deprecated this will become an error, and then the C-like behavior will become the default.

7. Optional ModuleInfo

   ModuleInfo is not a necessary feature of D. There are use cases where the program author may choose to provide an alternate implementation of the D runtime that does not include ModuleInfo. This could be for interoperability with other software or to reduce the footprint of D programs in resource constrained platforms.

   Prior to this release, the compiler would emit an error if ModuleInfo was not declared in the D runtime.

   Platform support is provided by the D runtime. ModuleInfo is declared in object.d. Therefore, the compiler can see, at compile-time, whether or not the platform has provided support for ModuleInfo and generate object code accordingly.

   Starting with this release, if ModuleInfo is not deсlared in the D runtime, the compiler will simply not generate ModuleInfo instances.

   This should reduce friction for those wishing to incrementally port D to new platforms and use D in a more pay-as-you-go fashion.

8. Added RAII and try-finally support for -betterC mode.

   This also means that scope(exit) statements will also work, because they are internally lowered to try-finally statements.

   This does not mean that exceptions are supported. Throwing, catching, and stack frame unwinding is not supported, as that requires support from Phobos.

   It means that, for RAII, when variables go out of lexical scope their destructors get run. When try blocks from try-finally statements exit, the code in the finally block is run.

9. Windows: dmd can now detect Visual Studio installation paths

   dmd now determines the environment variables that are usually set if the "Command Line prompt for Visual Studio" link is used to open a console window (or vcvarsall.bat is executed). This includes Windows SDK directories and Visual C library directories. When compiling with -m64 or -m32mscoff this allows dmd to invoke the linker without having a Visual Studio version preselected by the installer.

   In particular, the variables WindowsSdkDir, WindowsSdkVersion, UniversalCRTSdkDir, UCRTVersion, VSINSTALLDIR, VisualStudioVersion, VCINSTALLDIR and VCTOOLSINSTALLDIR are determined from the registry if they are not set in the environment or sc.ini.

   Supported Windows SDK range from 7.0A to 10.x, supported Visual Studio Versions are VS 2008 to VS 2017. If multiple versions are installed, highest versions are preferred.

#### Runtime changes

1. core.runtime now allows more fine-grained control over unittests.

   core.runtime.extendedModuleUnitTester property allows specifying information about the tests run, and how to handle the result. See documentation for core.runtime.UnitTestResult for details.

   core.runtime.moduleUnitTester (setting a unittest handler that returns bool) will continue to be supported for legacy projects.

       import core.runtime;
       import core.stdc.stdio: printf;

       UnitTestResult customTester()
       {
           UnitTestResult ret;

           // run only the tests in my package
           immutable prefix = "myPackage.";
           foreach (m; ModuleInfo)
           {
               if (m.unitTest !is null && m.name.length >= prefix.length &&
                     m.name[0 .. prefix.length] == prefix)
               {
                   ++ret.executed; // count unit tests run
                   try
                   {
                       m.unitTest();
                       ++ret.passed; // count unit tests passed
                   }
                   catch(Throwable t)
                   {
                       auto msg = t.toString();
                       printf("%.*s\n", cast(uint)msg.length, msg.ptr);
                   }
               }
           }
           // always summarize
           ret.summarize = true;
           // only unit testing, don't ever run main
           ret.runMain = false;
       }

       version(unittest) static shared this()
       {
           Runtime.extendedModuleUnitTester = &customTester;
       }

2. The runtime learned a few new options to customize how coverage reports are created.

   The format is the same as with the GC but using covopt as suffix, for example you can pass options separating them with spaces like `--DRT-covopt "merge:1 dstpath:/tmp"`.

   These are the currently accepted options:

   merge
     Merge the current run with existing reports if 1, or overwrite the existing reports if 0.
   srcpath
     Set path to where source files are located.
   dstpath
     Set path to where listing files are to be written.

#### Library changes

1. mean Was Added To std.algorithm

   std.algorithm.iteration.mean accurately finds the mean (a.k.a the average) of any range of number-like elements.

       import std.algorithm.iteration : mean;
       import std.math : approxEqual;

       int[] arr1 = [1, 2, 3];
       real[] arr2 = [1.5, 2.5, 12.5];

       assert(arr1.mean.approxEqual(2));
       assert(arr2.mean.approxEqual(5.5));

       // user defined number types also work
       import std.bigint : BigInt;

       auto bigint_arr = [
           BigInt("1_000_000_000_000_000_000"),
           BigInt("2_000_000_000_000_000_000"),
           BigInt("3_000_000_000_000_000_000"),
           BigInt("6_000_000_000_000_000_000")
       ];
       auto seed = BigInt(0);
       assert(bigint_arr.mean(seed) == BigInt("3_000_000_000_000_000_000"));

2. findSkip can now skip elements using just a predicate function

   Previously, std.algorithm.searching.findSkip could only be used to find a specific string. Now, a new overload allows elements in a range to be skipped over if the passed function returns true:

       import std.ascii : isWhite;
       string s = "   abc";
       assert(findSkip!isWhite(s) == 3 && s == "abc");
       assert(!findSkip!isWhite(s) && s == "abc");

3. std.array.byPair now returns a NamedTuple

   std.array.byPair now returns a named tuple.

       import std.array : byPair;
       import std.typecons : Tuple;

       int[string] dict = ["b": 2, "c": 3];
       auto pairs = dict.byPair;
       static assert(is(typeof(pairs.front) : Tuple!(string,int)));

       // access by index (existing way)
       assert(pairs.front[0] == "b");
       assert(pairs.front[1] == 2);

       // access by name (enabled with this release)
       assert(pairs.front.key == "b");
       assert(pairs.front.value == 2);

4. std.container.dlist supports linearRemoveElement

   linearRemoveElement removes the first occurence of an element from the dlist

       import std.container : Dlist;
       import std.algorithm.comparison : equal;

       auto a = DList!int(-1, 1, 2, 1, 3, 4);
       a.linearRemoveElement(1);
       assert(equal(a[], [-1, 2, 1, 3, 4]));

5. std.container.slist supports linearRemoveElement

   linearRemoveElement removes the first occurence of an element from the slist

       import std.container : Slist;
       import std.algorithm.comparison : equal;

       auto a = SList!int(-1, 1, 2, 1, 3, 4);
       a.linearRemoveElement(1);
       assert(equal(a[], [-1, 2, 1, 3, 4]));

6. Deprecate save for std.range.package.Transposed

   Transposed is incorrectly marked as a forward range. Its popFront primitive cannot be used without affecting any other copies made with save. save will be removed from Transposed in November 2018.

       auto x = [[1,2,3],[4,5,6]].transposed;
       auto y = x.save;
       y.popFront;
       assert(x.equal([[1,4],[2,5],[3,6]])); // FAILS, x is really [[2,5],[3,6]]

   For more details, please see the respective Bugzilla issue.

7. std.typecons.Ternary.opBinary supports bool bitwise operands

   Now std.typecons.Ternary can be used in bitwise operations with bools:

       import std.typecons : Ternary;

       Ternary a = Ternary(true);
       assert(a == Ternary.yes);
       assert((a & false) == Ternary.no);
       assert((a | false) == Ternary.yes);
       assert((a ^ true) == Ternary.no);
       assert((a ^ false) == Ternary.yes);

List of all bug fixes and enhancements in D 2.078.0:

#### DMD Compiler regressions

1. Bugzilla 17246: [REG2.053] Extra destructor call.
2. Bugzilla 17371: [REG 2.074.0] di generation broken for anonymous classes
3. Bugzilla 17559: [REG2.073.0] Wrong line number in stack trace
4. Bugzilla 17915: [REG 2.073] core.exception.AssertError@ddmd/optimize.d(614): Assertion failure
5. Bugzilla 17955: compiler segfault in DsymbolSemanticVisitor::visit(UnittestDeclaration*)
6. Bugzilla 18020: [Reg 2.078] no property opCmp for anon class
7. Bugzilla 18093: [Reg 2.071] MSCOFF: dmd crashes when overriding a C++ method in a mixin template
8. Bugzilla 18141: [REG2.078a] dmd -v no longer prints predefs

#### DMD Compiler bugs

1. Bugzilla 5332: Undefined reference to zero length array
2. Bugzilla 6400: opDispatch with WithStatement
3. Bugzilla 8262: ICE(mtype.c) alias this to alias of an expression tuple
4. Bugzilla 9290: Ability to modify immutable struct members in static array assignment
5. Bugzilla 10310: VRP for bitwise &|^ does not always produce the tightest bounds.
6. Bugzilla 11006: Subtraction of pointers for void and non-void types compiles
7. Bugzilla 12385: Enum member should not be modifiable when the member is immutable
8. Bugzilla 12496: __traits(parent, x) returns incorrect type
9. Bugzilla 12625: [scope] [DIP1000] implicit slicing of RValue static array should be illegal
10. Bugzilla 15094: __traits(getMember) fails when the source is a struct/class field
11. Bugzilla 15243: rejects-valid on variadic
12. Bugzilla 15289: VRP not working as expected on division
13. Bugzilla 15290: length of associative array literal with duplicate keys is wrong
14. Bugzilla 16649: Header gen skips parens
15. Bugzilla 16694: ICE on taking address of export function (declaration-only)
16. Bugzilla 16997: Integral promotion rules not being followed for unary + - ~ expressions
17. Bugzilla 17096: many traits accept an invalid parameter count without error
18. Bugzilla 17167: dmd fails to write to file or create directory with more than 248 characters in the path
19. Bugzilla 17382: void main(){}pragma(msg,main()); crashes DMD
20. Bugzilla 17585: Wrong error message for deprecated overrides
21. Bugzilla 17586: Overriding a deprecated base class function gives no warning
22. Bugzilla 17842: [scope] array append allows for escaping references
23. Bugzilla 17843: -betterC struct with double field generates references to TypeInfo
24. Bugzilla 17853: Switch statement without braces only works with one case
25. Bugzilla 17900: FreeBSD 10.3 runnable/cpp_abi_tests.d(94): Assertion failure (test suite)
26. Bugzilla 17908: Can't alias an overload set with disabled function
27. Bugzilla 17927: [scope] scope inout parameter value can be escaped via return
28. Bugzilla 17934: [scope] scopeness entrypoint for unique/ref-counted missing
29. Bugzilla 17935: [scope] auto-generated destructor not scope aware
30. Bugzilla 17940: bool function parameters loaded from struct sometimes miscompiled with -O
31. Bugzilla 17944: MSCOFF: debug info not compatible with LLVMs LLD
32. Bugzilla 17947: C++ std::pair::swap mangled incorrectly
33. Bugzilla 17976: core.exception.AssertError@ddmd/dsymbolsem.d(1624)
34. Bugzilla 17997: autotester's d_do_test has strange failures with Win32
35. Bugzilla 18013: DMD test suite assertion failure in test_cdvecfill.d
36. Bugzilla 18014: DMD test suite fails to link on Linux distros where PIC/PIE is enforced
37. Bugzilla 18045: Temporary created during comparison not destroyed
38. Bugzilla 18099: betterC check throw statements error!

#### DMD Compiler enhancements

1. Bugzilla 4946: Not good error message with wrongly positioned 'const'
2. Bugzilla 17256: Inconsistent output between json and ddoc
3. Bugzilla 17868: add pragma(crt_con/destructor)
4. Bugzilla 17878: Add __traits(isFuture, ...)
5. Bugzilla 18076: dmd -run should work with - (stdin) too

#### Phobos regressions

1. Bugzilla 17962: dirEntries now truncates Unicode file names
2. Bugzilla 17986: Erratic failure with std/experimental/allocator/common.d(445): unittest failure
3. Bugzilla 18084: [REG2.072] tempCString buffer size is unittest-versioned

#### Phobos bugs

1. Bugzilla 2447: There's no disconnectall for std.signals
2. Bugzilla 6820: etc.c.curl missing const
3. Bugzilla 6895: std.traits.isCovariantWith doesn't work for function, function pointer and delegate
4. Bugzilla 9661: LockingTextWriter should increment file handle reference count
5. Bugzilla 10395: [std.stdio] Closing a popened File with unread output throws an exception
6. Bugzilla 12064: std.typecons.wrap doesn't handle NVI
7. Bugzilla 14477: Nullable does not work with structs with default constructor disabled
8. Bugzilla 15140: std.experimental.allocator.building_blocks.free_list.FreeList leaks memory
9. Bugzilla 15637: Region allocator assert failure when expanding the last allocation
10. Bugzilla 16253: BitmappedBlock allocator not working with chooseAtRuntime
11. Bugzilla 16542: makeArray not usable with const initializer
12. Bugzilla 16564: KRRegion.empty sometimes returns Ternary.no
13. Bugzilla 17459: format("%012,3d", ...) doesn't handle field width and zero-padding correctly
14. Bugzilla 17467: BitArray are broken with <<= 64
15. Bugzilla 17730: [scope][dip1000] std.algorithm.move escapes scope variable in @safe code
16. Bugzilla 17901: FreeBSD 10.3: AssertError@std/experimental/allocator/building_blocks/region.d(652)
17. Bugzilla 17995: template NoDuplicates(TList...) bug.
18. Bugzilla 18044: std.conv.to for implicitly convertible associative arrays
19. Bugzilla 18047: std.format value.length modulo seperator step width leads to wrong length
20. Bugzilla 18092: Can't combine take and takeExactly
21. Bugzilla 18135: [REG2.078] can't join RegexMatch anymore

#### Phobos enhancements

1. Bugzilla 1998: std.bitarray should have setAll / opSliceAssign(bool) etc
2. Bugzilla 4717: std.bitmanip.BitArray changes
3. Bugzilla 4763: std.stdio.File.open() : more efficient implementation
4. Bugzilla 6244: Add powmod / modpow function to std.math
5. Bugzilla 9362: Add a method to remove one item to std.container.SList
6. Bugzilla 13532: std.regex performance (enums; regex vs ctRegex)
7. Bugzilla 14034: std.algorithm.mean
8. Bugzilla 16398: experimental allocators, add aligned reallocation for Posix
9. Bugzilla 17742: std.range.transposed does not have opIndex
10. Bugzilla 17905: byCodeUnit should allow access to underlying range
11. Bugzilla 17919: std.container.Array could use pureMalloc
12. Bugzilla 17952: std.range.transposed save is invalid
13. Bugzilla 18021: FileLogger Member not accessible to subclasses

#### Druntime regressions

1. Bugzilla 17914: [Reg 2.075] Fibers guard page uses a lot more memory mappings
2. Bugzilla 18071: [REG2.078] byKey, byValue and byKeyValue are now a hole for unsafe code

#### Druntime bugs

1. Bugzilla 17108: Associative array byKeyValue is unsafe
2. Bugzilla 17851: htonl already defined in phobos64.lib
3. Bugzilla 17956: core.memory unittest failure (possibly glibc 2.26 specific)

#### Druntime enhancements

1. Bugzilla 17300: Enable setting code coverage options on the command line

#### dlang.org bugs

1. Bugzilla 18033: Open in Editor button doesn't work

#### dlang.org enhancements

1. Bugzilla 16392: drop win32.mak
2. Bugzilla 17265: WithStatement: Find better Example for what "with" really does
3. Bugzilla 17527: dlangspec.pdf: escape sequences table goes over the page boundaries
4. Bugzilla 17529: dlangspec.pdf: grammar definitions go over the right margin
5. Bugzilla 17531: dlangspec.pdf: overloading unary operators exposes LaTeX
6. Bugzilla 17534: dlangspec.pdf: 25.24: getFunctionVariadicStyle's tables goes over the page margin and uses HTML
7. Bugzilla 17535: dlangspec.pdf: enforce a maximal width for all code examples
8. Bugzilla 17536: dlangspec.pdf: Unittests documentation uses HTML
9. Bugzilla 17538: dlangspec.pdf: 33.14 Comparing D Immutable and Const with C++ Const goes over the page margin
10. Bugzilla 17723: Replace Facebook on the front page with Weka.io
11. Bugzilla 17925: [Contract Programming]
12. Bugzilla 17993: 404 Not Found: phobos/ddmd_utf.html
13. Bugzilla 18032: [Home] Print hex dump example doesn't run
14. Bugzilla 18067: Benchmark example is broken on the frontpage
15. Bugzilla 18081: dlangspec.pdf: don't escape dollars in code examples
16. Bugzilla 18082: Ubuntu/Debian repository installation should mention dub

#### Tools bugs

1. Bugzilla 7997: Optlink issues 'Index Range' error with static zero length array

### Contributors to this release (57)

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

- abaga129
- aG0aep6G
- aldacron
- Alexandru Caciulescu
- Alexandru Jercaianu
- Andrei Alexandrescu
- Atila Neves
- Basile Burg
- Benoit Rostykus
- Brad Roberts
- Chris Coutinho
- Dashster
- Dmitry Olshansky
- Dragos Carp
- dukc
- Eduard Staniloiu
- H. S. Teoh
- Iain Buclaw
- Ilya Yaroshenko
- Jack Stouffer
- Jean-Louis Leroy
- JinShil
- Joakim Noah
- Johan Engelen
- John Colvin
- Jon Degenhardt
- Jonathan M Davis
- Jonathan Marler
- Jordi Sayol
- Kevin De Keyser
- kinke
- Kotet
- Laeeth Isharc
- Leandro Lucarella
- Lucia Mcojocaru
- Martin Krejcirik
- Martin Nowak
- Mathias Lang
- Mathis Beer
- MetaLang
- n8sh
- Nemanja Boric
- Nick Treleaven
- Oleg Nykytenko
- Petar Kirov
- Rainer Schuetze
- Razvan Nitu
- Robert burner Schadek
- Sebastian Wilzbach
- Simen Kjærås
- skl131313
- Steven Schveighoffer
- Temtaime
- Vladimir Panteleev
- Walter Bright
- yashikno
- Yuxuan Shui

Copyright © 1999-2018 by the D Language Foundation | Page generated by Ddoc on Sat Apr 14 16:39:10 2018