Skip to content

Commit

Permalink
Merge pull request dlang#4779 from 9rnsr/fix14735
Browse files Browse the repository at this point in the history
[REG2.068-b1] Issue 14735 - std.string.indexOf cannot deduce function for char argument
  • Loading branch information
WalterBright authored and 9rnsr committed Jun 30, 2015
1 parent 86757a2 commit c2b84a0
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
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
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 c2b84a0

Please sign in to comment.