From 9ea37042d7fdb6ffdfae6a945693c63a2b9c584d Mon Sep 17 00:00:00 2001 From: Nick Treleaven Date: Fri, 19 Jun 2020 17:20:51 +0100 Subject: [PATCH] Fix Issue #17712 - Add test cases --- test/compilable/b17712.d | 40 ++++++++++++++++++++++++++ test/compilable/b17712_c13.d | 54 ++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 test/compilable/b17712.d create mode 100644 test/compilable/b17712_c13.d diff --git a/test/compilable/b17712.d b/test/compilable/b17712.d new file mode 100644 index 000000000000..ce4a234546e0 --- /dev/null +++ b/test/compilable/b17712.d @@ -0,0 +1,40 @@ +// REQUIRED_ARGS: -main +// https://issues.dlang.org/show_bug.cgi?id=17712 + +struct Bytecode +{ + uint data; +} + +@trusted ctSub(U)(string format, U args) +{ + import std.conv : to; + foreach (i; format) + return format~ to!string(args); + return format; +} + +struct CtContext +{ + import std.uni : CodepointSet; + + CodepointSet[] charsets; + + string ctAtomCode(Bytecode[] ir) + { + string code; + switch (code) + { + OrChar: + code ~= ``; + for (uint i ; i ;) + code ~= ctSub(``, ir[i].data); + charsets[ir[0].data].toSourceCode; + break; + + default: + assert(0); + } + return code; + } +} diff --git a/test/compilable/b17712_c13.d b/test/compilable/b17712_c13.d new file mode 100644 index 000000000000..0f7f8596c29f --- /dev/null +++ b/test/compilable/b17712_c13.d @@ -0,0 +1,54 @@ +// https://issues.dlang.org/show_bug.cgi?id=17712#c13 + +import std.datetime; +import std.typecons; +import std.variant; + + +Y a() +{ + Y n = Y(Y[].init); + + n.get!(X[]); + return n; +} + +struct X +{ + Y key; +} +struct Y +{ + Algebraic!(Y[]) value_; + this(T)(T value) + { + value_ = value; + } + bool opEquals(T)(T rhs) const + { + static if(is(Unqual!T == Y)) + { + return true; + } + else + { + return get!(T, No.x) == get!T; + } + } + T get(T, Flag!"x" x = Yes.x)() const + { + return this[""].get!(T, x); + } + + Y opIndex(T)(T index) const + { + const X[] pairs; + if(pairs[0].key == index) + { + assert(0); + } + assert(0); + } +} + +void main(){}