The following program causes an assertion failure in statement.c with current it head:
DMD64 D Compiler v2.066-devel-75159e4
import std.algorithm;
int foo(int value)
{
return value;
}
void main()
{
reduce!(foo, foo)(tuple(0, 0), [ 1 ]);
}
statement.c:274: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors' failed.
*** Issue 12517 has been marked as a duplicate of this issue. ***
Comment #4 by monarchdodra — 2014-04-13T19:18:52Z
Was this fixed? I can reproduce it with this case:
//----
void main()
{
import std.algorithm: min, max, reduce;
import std.typecons: tuple;
dchar c = 'a';
reduce!(min, max)(tuple(c, c, c), "hello"); // OK
}
//----
dmd: statement.c:713: ErrorStatement::ErrorStatement(): Assertion `global.gaggedErrors || global.errors' failed.
Aborted (core dumped)
//----
Or, reduced to:
//----
import std.traits, std.functional;
template reduce(fun...)
{
auto reduce(Seed)(Seed result)
{
foreach (i, Unused; Seed.Types)
result[i] = binaryFun!(fun[i])(1, 1); //Here
return result;
}
}
void main()
{
import std.typecons: tuple;
reduce!("a", "a")(tuple(1, 1, 1));
}
//----
I think the root issue is in:
result[i] = binaryFun!(fun[i])(1, 1); //Here
Changing to either:
auto a = binaryFun!(fun[i])(1, 1);
or
result[i] = fun[i](1, 1);
Allows it to "fail correctly"
...
Or is it a different issue?
Comment #5 by monarchdodra — 2014-04-13T19:32:52Z
(In reply to monarchdodra from comment #4)
> Was this fixed? I can reproduce it with this case:
Bearophile filed at as its own issue:
https://issues.dlang.org/show_bug.cgi?id=12569
Don't know which you'd rather close (eg: deplicate, or leave this as fixed).
Comment #6 by monarchdodra — 2014-04-13T19:33:59Z
(In reply to monarchdodra from comment #4)
> Was this fixed? I can reproduce it with this case:
Bearophile filed at as its own issue:
https://issues.dlang.org/show_bug.cgi?id=12574
Don't know which you'd rather close (eg: deplicate, or leave this as fixed).
Comment #7 by k.hara.pg — 2014-04-15T07:22:14Z
(In reply to monarchdodra from comment #6)
> (In reply to monarchdodra from comment #4)
> > Was this fixed? I can reproduce it with this case:
>
> Bearophile filed at as its own issue:
> https://issues.dlang.org/show_bug.cgi?id=12574
>
> Don't know which you'd rather close (eg: deplicate, or leave this as fixed).
I opened new compiler PR to fix issue 12574.