Skip to content

Commit

Permalink
Merge pull request #3733 from 9rnsr/fix13024
Browse files Browse the repository at this point in the history
[REG2.066a] Issue 13024 - [ICE](expression.c line 1172) with implicit supertype conversion of different enums in array literal
  • Loading branch information
WalterBright committed Jul 11, 2014
2 parents 49f0db5 + aec7dff commit e0ca2d2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/expression.c
Expand Up @@ -1169,7 +1169,16 @@ bool arrayExpressionToCommonType(Scope *sc, Expressions *exps, Type **pt)
{
Expression *e = (*exps)[i];
e = e->implicitCastTo(sc, t0);
assert(e->op != TOKerror);
//assert(e->op != TOKerror);
if (e->op == TOKerror)
{
/* Bugzilla 13024: a workaround for the bug in typeMerge -
* it should paint e1 and e2 by deduced common type,
* but doesn't in this particular case.
*/
t0 = Type::terror;
break;
}
(*exps)[i] = e;
}
}
Expand Down
16 changes: 16 additions & 0 deletions test/fail_compilation/ice13024.d
@@ -0,0 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/ice13024.d(15): Error: cannot implicitly convert expression (t.x) of type A to B
---
*/

enum A { a }
enum B { b }
struct T { A x; B y; }
void main()
{
T t;
auto r1 = [cast(int)(t.x), cast(int)(t.y)]; // OK
auto r3 = [t.x, t.y]; // crash
}

0 comments on commit e0ca2d2

Please sign in to comment.