Comment #0 by dimitri.sabadie — 2012-11-02T04:38:54Z
I have found something interresting with lambdas. Consider this:
string modules[] = [ "foo", "bar", "zoo" ];
string line;
/* ... */
/* now line contains something not empty */
if (any!(a => a == line)(modules)) {
/* ... */
}
I get a DMD assertion crash on the if statement:
Assertion failure: '!vthis->csym' on line 727 in file 'glue.c'
Of course, the lambda syntax is, here,
(string a) => a == line
But sometimes a => a == line also works as inference type lambda! I don’t know why it doesn’t here. Also, this works too:
(string a) { return a == line; }
Is it the old delegate literal syntax?
Comment #1 by dimitri.sabadie — 2012-11-02T04:40:29Z
Just to precise — as the topic name does — DMD fails to say that the error is on the lambda expression in the if statement. Instead it prints internal shit assertions.
Comment #2 by maxim — 2012-11-02T05:03:14Z
Regarding lambdas - it is well-known issue which consists in treating lambda expression as voids: see issue 8899. Regarding internal compiler error - please provide exact code which shows problem.
Comment #3 by ds.dlang — 2012-12-17T01:24:08Z
I tried to reproduce, but the following code compiles and works correctly with dmd built from the current github head (on MacOSX):
import std.stdio;
import std.algorithm;
string modules[] = [ "foo", "bar", "zoo" ];
int main(string[] args) {
foreach (string line; ["hello", "bar", "world"]) {
if (any!(a => a == line)(modules)) {
writeln(line, " found");
} else {
writeln(line, " not found");
}
}
return 0;
}
Comment #4 by braddr — 2013-03-16T12:39:52Z
Based on the last comment, it's no longer reproducible. This means that this bug was likely a duplicate of another which was fixed between when the but was reported and then re-tested.
Please feel free to re-open if you can reproduce it.