Skip to content

Commit

Permalink
fix Issue 15065 - associative array has no keys property
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 27, 2015
1 parent 3b02f50 commit 082ba6b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -6907,38 +6907,32 @@ public:

final void resolveExprType(Loc loc, Scope* sc, Expression e, size_t i, Expression* pe, Type* pt)
{
//printf("resolveExprType(e = %s %s, type = %s)\n", Token::toChars(e->op), e->toChars(), e->type->toChars());
e = e.semantic(sc);
//printf("resolveExprType(e = %s %s, type = %s)\n", Token.toChars(e.op), e.toChars(), e.type.toChars());
for (; i < idents.dim; i++)
{
if (e.op == TOKerror)
break;
RootObject id = idents[i];
//printf("e: '%s', id: '%s', type = %s\n", e->toChars(), id->toChars(), e->type->toChars());
if (id.dyncast() == DYNCAST_IDENTIFIER)
{
auto die = new DotIdExp(e.loc, e, cast(Identifier)id);
e = die.semanticY(sc, 0);
e = new DotIdExp(e.loc, e, cast(Identifier)id);
}
else if (id.dyncast() == DYNCAST_TYPE) // Bugzilla 1215
{
e = new IndexExp(loc, e, new TypeExp(loc, cast(Type)id));
e = e.semantic(sc);
}
else if (id.dyncast() == DYNCAST_EXPRESSION) // Bugzilla 1215
{
e = new IndexExp(loc, e, cast(Expression)id);
e = e.semantic(sc);
}
else
{
assert(id.dyncast() == DYNCAST_DSYMBOL);
TemplateInstance ti = (cast(Dsymbol)id).isTemplateInstance();
assert(ti);
auto dte = new DotTemplateInstanceExp(e.loc, e, ti.name, ti.tiargs);
e = dte.semanticY(sc, 0);
e = new DotTemplateInstanceExp(e.loc, e, ti.name, ti.tiargs);
}
}
e = e.semantic(sc);
if (e.op == TOKerror)
*pt = Type.terror;
else if (e.op == TOKtype)
Expand Down
14 changes: 14 additions & 0 deletions test/runnable/ufcs.d
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,20 @@ void test11312()
assert(x == 10);
}

/*******************************************/
// 15123

auto keys15123(K, V)(V[K] aa) { return [1]; }
auto values15123(K, V)(V[K] aa) { return [2]; }

alias id15123(alias arg) = arg;

enum int[int] aa15123 = [1:2];
static assert(id15123!(aa15123.keys15123) == [1]); // TypeIdentifier + UFCS

T[T] f15123(T)() { return [1:2]; }
static assert(id15123!(f15123!int.values15123) == [2]); // TypeInstance + UFCS

/*******************************************/

int main()
Expand Down

0 comments on commit 082ba6b

Please sign in to comment.