From b3f58f87d78b958e35e4a44f5fdb4b7721cb2837 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Mon, 20 Dec 2021 19:25:32 +0100 Subject: d: Merge upstream dmd ad8412530, druntime fd9a4544, phobos 495e835c2. D front-end changes: - Import dmd v2.098.1 - Remove calling of _d_delstruct from code generator. Druntime changes: - Import druntime v2.098.1 Phobos changes: - Import phobos v2.098.1 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd ad8412530. * expr.cc (ExprVisitor::visit (DeleteExp *)): Remove code generation of _d_delstruct. * runtime.def (DELSTRUCT): Remove. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime fd9a4544. * src/MERGE: Merge upstream phobos 495e835c2. --- libphobos/src/std/format/write.d | 23 +++++++++++++++++++++++ libphobos/src/std/range/interfaces.d | 9 +++++++++ libphobos/src/std/typecons.d | 2 +- 3 files changed, 33 insertions(+), 1 deletion(-) (limited to 'libphobos/src/std') diff --git a/libphobos/src/std/format/write.d b/libphobos/src/std/format/write.d index c758768..e67d95c 100644 --- a/libphobos/src/std/format/write.d +++ b/libphobos/src/std/format/write.d @@ -1287,3 +1287,26 @@ void formatValue(Writer, T, Char)(auto ref Writer w, auto ref T val, scope const assertThrown!FormatException(formattedWrite(w, "%(%0*d%)", new int[1])); } + +// https://issues.dlang.org/show_bug.cgi?id=22609 +@safe pure unittest +{ + static enum State: ubyte { INACTIVE } + static struct S { + State state = State.INACTIVE; + int generation = 1; + alias state this; + // DMDBUG: https://issues.dlang.org/show_bug.cgi?id=16657 + auto opEquals(S other) const { return state == other.state && generation == other.generation; } + auto opEquals(State other) const { return state == other; } + } + + import std.array : appender; + import std.format.spec : singleSpec; + + auto writer = appender!string(); + const spec = singleSpec("%s"); + S a; + writer.formatValue(a, spec); + assert(writer.data == "0"); +} diff --git a/libphobos/src/std/range/interfaces.d b/libphobos/src/std/range/interfaces.d index 475f35b..6d55d414 100644 --- a/libphobos/src/std/range/interfaces.d +++ b/libphobos/src/std/range/interfaces.d @@ -201,6 +201,9 @@ interface RandomAccessFinite(E) : BidirectionalRange!(E) { /**Interface for an infinite random access range of type `E`.*/ interface RandomAccessInfinite(E) : ForwardRange!E { + /// + enum bool empty = false; + /**Calls $(REF moveAt, std, range, primitives) on the wrapped range, if * possible. Otherwise, throws an $(LREF UnsupportedRangeMethod) exception. */ @@ -213,6 +216,12 @@ interface RandomAccessInfinite(E) : ForwardRange!E { E opIndex(size_t); } +// https://issues.dlang.org/show_bug.cgi?id=22608 +@safe unittest +{ + static assert(isRandomAccessRange!(RandomAccessInfinite!int)); +} + /**Adds assignable elements to InputRange.*/ interface InputAssignable(E) : InputRange!E { /// diff --git a/libphobos/src/std/typecons.d b/libphobos/src/std/typecons.d index 6dee863..cde2b9d 100644 --- a/libphobos/src/std/typecons.d +++ b/libphobos/src/std/typecons.d @@ -6971,7 +6971,7 @@ mixin template Proxy(alias a) static if (is(typeof(a.opCmp(b)))) return a.opCmp(b); else static if (is(typeof(b.opCmp(a)))) - return -b.opCmp(b); + return -b.opCmp(a); else return a < b ? -1 : a > b ? +1 : 0; } -- cgit v1.1