diff --git a/source/dyaml/node.d b/source/dyaml/node.d index 4c3c5eb..a043e54 100644 --- a/source/dyaml/node.d +++ b/source/dyaml/node.d @@ -1691,7 +1691,9 @@ Pair(k3, Node(cast(real)1.0)), Pair(k4, Node("yarly"))]); - foreach(scope string key, scope Node value; nmap2) + // DUB: `scope` in `foreach` not supported before 2.098 + int dummy; // Otherwise the delegate is infered as a function + nmap2.opApply((scope string key, scope Node value) { switch(key) { @@ -1701,7 +1703,8 @@ case "14": assert(value.as!string == "yarly"); break; default: assert(false); } - } + return dummy; + }); const nmap3 = nmap2; foreach(const Node key, const Node value; nmap3) diff --git a/source/dyaml/stdsumtype.d b/source/dyaml/stdsumtype.d index 3dac4dd..5588a53 100644 --- a/source/dyaml/stdsumtype.d +++ b/source/dyaml/stdsumtype.d @@ -392,38 +392,45 @@ tag = tid; } - static if (isCopyable!(const(T))) + // DUB: Those traits compile work around bugs in < v2.098 + static if (!__traits(compiles, { T c = const(T).init; })) { - static if (IndexOf!(const(T), Map!(ConstOf, Types)) == tid) + static if (isCopyable!(const(T))) { - /// ditto - this(const(T) value) const + static if (IndexOf!(const(T), Map!(ConstOf, Types)) == tid) { - __traits(getMember, storage, Storage.memberName!T) = value; - tag = tid; + /// ditto + this(const(T) value) const + { + __traits(getMember, storage, Storage.memberName!T) = value; + tag = tid; + } } } - } - else - { - @disable this(const(T) value) const; + else + { + @disable this(const(T) value) const; + } } - static if (isCopyable!(immutable(T))) + static if (!__traits(compiles, { T c = immutable(T).init; })) { - static if (IndexOf!(immutable(T), Map!(ImmutableOf, Types)) == tid) + static if (isCopyable!(immutable(T))) { - /// ditto - this(immutable(T) value) immutable + static if (IndexOf!(immutable(T), Map!(ImmutableOf, Types)) == tid) { - __traits(getMember, storage, Storage.memberName!T) = value; - tag = tid; + /// ditto + this(immutable(T) value) immutable + { + __traits(getMember, storage, Storage.memberName!T) = value; + tag = tid; + } } } - } - else - { - @disable this(immutable(T) value) immutable; + else + { + @disable this(immutable(T) value) immutable; + } } static if (isCopyable!(inout(T)))