Comment #1 by ben.james.jones — 2020-04-14T19:41:27Z
Reduced test case:
import std.meta : AliasSeq;
import std.typecons : ReplaceTypeUnless;
import std.traits : isCopyable, isAssignable;
struct This; //defined in std.variant this way
struct SumType(TypeArgs)
{
alias Types = AliasSeq!(ReplaceTypeUnless!(isSumType, This, typeof(this), TypeArgs));
union Storage
{
template memberName(T)
{
mixin("enum memberName = `values_", "`;");
}
static foreach (T; Types)
mixin("T ", memberName!T, ";");
}
Storage storage;
static foreach (T; Types) static if (isCopyable!T){}
static foreach (T; Types) static if (isAssignable!T){}
}
enum isSumType(T) = is(Args);
struct B {
SumType!(This)elems;
}
Comment #2 by moonlightsentinel — 2020-04-15T02:16:36Z
Maybe related reduction from dustmite:
==============================
alias AliasSeq(TList...) = TList;
enum isCopyable(S) = { S foo; };
struct SumType
{
alias Types = AliasSeq!(typeof(this));
Types[0] t;
alias cp = isCopyable!(Types[0]);
}
================================
This also segfaults but prints
test.d(6): Error: struct test.SumType cannot have field t with same struct type
Comment #3 by ben.james.jones — 2020-04-15T02:45:41Z
Not sure it's the same bug since mine triggers a stack overflow with no diagnostics. Here's the dustmite script I used to reduce:
#!/bin/sh
# arguments to dmd
DMDARGS="test20719.d"
OUTPUT=$(lldb --batch -o "run $DMDARGS" -k 'bt 30' -k 'quit' -o 'quit' dmd 2>&1)
#echo $OUTPUT
echo "$OUTPUT" | egrep -q "_D3dmd4func15FuncDeclaration14isTypeIsolatedMFCQBt5mtype4TypeZb"
exit $?
Comment #4 by moonlightsentinel — 2020-04-15T03:05:45Z
Without error message:
================================
struct SumType
{
alias Types = AliasSeq!(typeof(this));
union Storage
{
Types[0] t;
}
Storage storage;
static if (isCopyable!(Types[0])) {}
static if (isAssignable!(Types[0])) {}
}
alias AliasSeq(TList...) = TList;
enum isAssignable(Rhs) = __traits(compiles, lvalueOf = rvalueOf!Rhs);
struct __InoutWorkaroundStruct {}
T rvalueOf(T)();
T lvalueOf()(__InoutWorkaroundStruct);
enum isCopyable(S) = { S foo; };
=====================================
Both original and reduction cause a segfault for me.
Comment #5 by dlang-bot — 2020-04-30T17:59:32Z
@benjones created dlang/dmd pull request #11083 "fix issue 20719 by passing previously seen structs to isTypeIsolated …" fixing this issue:
- fix issue 20719 by passing previously seen structs to isTypeIsolated recursive calls
https://github.com/dlang/dmd/pull/11083
Comment #6 by dlang-bot — 2020-05-04T15:34:04Z
dlang/dmd pull request #11083 "fix issue 20719 by passing previously seen structs to isTypeIsolated …" was merged into master:
- 9fa18aa20a9975b2c5673522a4761a564c8b067b by Ben Jones:
fix issue 20719 by passing previously seen structs to isTypeIsolated recursive calls
https://github.com/dlang/dmd/pull/11083