Skip to content

Commit

Permalink
Merge pull request #8072 from JinShil/fix_18645
Browse files Browse the repository at this point in the history
Fix Issue 18645 - DMD segmentation fault (Enum Initialization)
  • Loading branch information
WalterBright authored Mar 25, 2018
2 parents cee0643 + 5c11b29 commit faa6f89
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
return errorReturn();

Expression eprev = emprev.value;
Type tprev = eprev.type.equals(em.ed.type) ? em.ed.memtype : eprev.type;
// .toHeadMutable() due to https://issues.dlang.org/show_bug.cgi?id=18645
Type tprev = eprev.type.toHeadMutable().equals(em.ed.type.toHeadMutable())
? em.ed.memtype
: eprev.type;

Expression emax = tprev.getProperty(em.ed.loc, Id.max, 0);
emax = emax.expressionSemantic(sc);
Expand Down
9 changes: 9 additions & 0 deletions test/compilable/test18645.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// https://issues.dlang.org/show_bug.cgi?id=18645

immutable INIT = 42;

enum A
{
x = INIT,
y
}

0 comments on commit faa6f89

Please sign in to comment.