Skip to content

Commit

Permalink
fix Issue 8453 - Associative array keys refused as property by sort
Browse files Browse the repository at this point in the history
This is a regression of refactoring around UFCS mechanism.
Introduced commit: e9538dc
  • Loading branch information
9rnsr committed Jul 28, 2012
1 parent c607144 commit 9ea5769
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/expression.c
Expand Up @@ -7463,11 +7463,14 @@ Expression *CallExp::resolveUFCS(Scope *sc)
if (e->op == TOKerror || !e->type)
return NULL;

if (e->op == TOKtype || e->op == TOKimport)
if (e->op == TOKtype || e->op == TOKimport || e->op == TOKdotexp)
return NULL;

//printf("resolveUCSS %s, e->op = %s\n", toChars(), Token::toChars(e->op));
e = resolveProperties(sc, e);

Type *t = e->type->toBasetype();
//printf("resolveUCSS %s, e = %s, %s, %s\n",
// toChars(), Token::toChars(e->op), t->toChars(), e->toChars());
if (t->ty == Taarray)
{
if (tiargs)
Expand Down
30 changes: 30 additions & 0 deletions test/runnable/ufcs.d
Expand Up @@ -314,6 +314,34 @@ void test8252()
static assert( 0.f); // fail
}

/*******************************************/
// 8453

T[] sort8453(T)(T[] a) { return a; }

void test8453()
{
int[int] foo;
auto bar1 = foo.keys().sort8453(); // OK
auto bar2 = foo.keys.sort8453(); // Error
}

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

template Signal4()
{
void connect(){}
}
struct S4
{
mixin Signal4!() s;
}
void test4()
{
S4 s;
s.s.connect(); // s.s is TOKdotexp, so never match UFCS
}

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

int main()
Expand All @@ -329,6 +357,8 @@ int main()
test7943();
test8180();
test8252();
test8453();
test4();

printf("Success\n");
return 0;
Expand Down

0 comments on commit 9ea5769

Please sign in to comment.