Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue 20894 - ICE: passing a member template mixin identifier as … #11211

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/dmd/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -6612,6 +6612,14 @@ extern (C++) class TemplateInstance : ScopeDsymbol
sa = (cast(DotTemplateExp)ea).td;
goto Ldsym;
}
if (ea.op == TOK.dot)
{
if (auto se = (cast(DotExp)ea).e2.isScopeExp())
{
sa = se.sds;
goto Ldsym;
}
}
}
else if (sa)
{
Expand Down Expand Up @@ -7394,7 +7402,8 @@ bool definitelyValueParameter(Expression e)
e.op == TOK.type || e.op == TOK.dotType ||
e.op == TOK.template_ || e.op == TOK.dotTemplateDeclaration ||
e.op == TOK.function_ || e.op == TOK.error ||
e.op == TOK.this_ || e.op == TOK.super_)
e.op == TOK.this_ || e.op == TOK.super_ ||
e.op == TOK.dot)
return false;

if (e.op != TOK.dotVariable)
Expand Down
46 changes: 46 additions & 0 deletions test/compilable/test20894.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// https://issues.dlang.org/show_bug.cgi?id=20894

mixin template MT()
{
int a;
alias b = char;
void c() {}
}

struct S
{
mixin MT mt;
}

void main()
{
auto r = S();
enum c = S();

foo!(S.mt);
foo!(r.mt);
foo!(c.mt); // OK <- ICE

foo!(mixin("S.mt"));
foo!(mixin("r.mt")); // OK <- ICE
foo!(mixin("c.mt")); // OK <- ICE

// some checks
foo!(r.mt, c.mt);
foo!(mixin("r.mt"), c.mt);
foo!(r.mt, mixin("c.mt"));
foo!(S.mt, mixin("c.mt"));
}

alias Tup(T...) = T;

void foo(A...)()
{
static if (A.length == 2)
{
static assert(__traits(isSame, A[0], A[1]));
enum members = __traits(allMembers, A[0]);
static assert(members == __traits(allMembers, A[1]));
static assert(members == Tup!("a", "b", "c"));
}
}