Skip to content

Commit

Permalink
fix Issue 14735 - std.string.indexOf cannot deduce function for char …
Browse files Browse the repository at this point in the history
…argument
  • Loading branch information
9rnsr committed Jun 27, 2015
1 parent 6071f1d commit 13a16e8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/cast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,7 @@ MATCH implicitConvTo(Expression *e, Type *t)

Type *tb = t->toBasetype();
Type *typeb = e->type->toBasetype();
if (tb->ty == Tsarray && typeb->ty == Tarray &&
e->lwr && e->upr)
if (tb->ty == Tsarray && typeb->ty == Tarray)
{
typeb = toStaticArrayType(e);
if (typeb)
Expand Down
25 changes: 25 additions & 0 deletions test/runnable/template9.d
Original file line number Diff line number Diff line change
Expand Up @@ -4573,6 +4573,30 @@ template SubOps14568(Args...)

struct Nat14568 { mixin SubOps14568!(null); }

/******************************************/
// 14735

enum CS14735 { yes, no }

int indexOf14735a(Range )(Range s, in dchar c) { return 1; }
int indexOf14735a(T, size_t n)(ref T[n] s, in dchar c) { return 2; }

int indexOf14735b(Range )(Range s, in dchar c, in CS14735 cs = CS14735.yes) { return 1; }
int indexOf14735b(T, size_t n)(ref T[n] s, in dchar c, in CS14735 cs = CS14735.yes) { return 2; }

void test14735()
{
char[64] buf;

// Supported from 2.063: (http://dlang.org/changelog#implicitarraycast)
assert(indexOf14735a(buf[0..32], '\0') == 2);
assert(indexOf14735b(buf[0..32], '\0') == 2);

// Have to work as same as above.
assert(indexOf14735a(buf[], '\0') == 2);
assert(indexOf14735b(buf[], '\0') == 2);
}

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

int main()
Expand Down Expand Up @@ -4683,6 +4707,7 @@ int main()
test13379();
test13484();
test13694();
test14735();

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

0 comments on commit 13a16e8

Please sign in to comment.