Skip to content

Commit

Permalink
Fix Issue 18429 - alias this enum causes segmentation fault
Browse files Browse the repository at this point in the history
  • Loading branch information
RazvanN7 committed Feb 14, 2018
1 parent 97e6d51 commit df08cb6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
Declaration d = sx.isDeclaration();
if (d && !d.isTupleDeclaration())
{
/* https://issues.dlang.org/show_bug.cgi?id=18429
*
* If the identifier in the AliasThis declaration
* is defined later and is a voldemort type, we must
* perform semantic on the declaration to deduce the type.
*/
if (!d.type)
d.dsymbolSemantic(sc);

Type t = d.type;
assert(t);
if (ad.type.implicitConvTo(t) > MATCH.nomatch)
Expand Down
7 changes: 7 additions & 0 deletions test/compilable/aliasdecl.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ void main()
static assert(is(Y4 == void delegate() const));
static assert(is(Y5.Type == int));

// Issue 18429
struct S
{
alias a this;
enum a = 1;
}

/+ struct S
{
int value;
Expand Down

0 comments on commit df08cb6

Please sign in to comment.