January 04, 2013 Type inference + forwarding lambda predicate | ||||
---|---|---|---|---|
| ||||
The following code results in a Segmentation fault: 11. The reason seems to be because "any" is called indefinitely. But if I don't use type inference for the lambda it works correctly. import algorithm = std.algorithm; bool any (alias predicate, Range) (Range range) { return algorithm.any!(predicate)(range); } void main () { auto arr = ["foo"]; any!(e => e == "asd")(arr); // segfault // any!((string e) => e == "asd")(arr); // works } Am I doing something wrong or is this a bug? -- /Jacob Carlborg |
January 04, 2013 Re: Type inference + forwarding lambda predicate | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Friday, 4 January 2013 at 16:06:38 UTC, Jacob Carlborg wrote: > The following code results in a Segmentation fault: 11. The reason seems to be because "any" is called indefinitely. But if I don't use type inference for the lambda it works correctly. > > import algorithm = std.algorithm; > > bool any (alias predicate, Range) (Range range) > { > return algorithm.any!(predicate)(range); > } > > void main () > { > auto arr = ["foo"]; > any!(e => e == "asd")(arr); // segfault > // any!((string e) => e == "asd")(arr); // works > } > > Am I doing something wrong or is this a bug? Seems to be a lambda bug. Take a look at http://d.puremagic.com/issues/show_bug.cgi?id=8774 especially last Walter's comments. He has fixed many similar issues but there are still some problems. This appears to be another one. |
Copyright © 1999-2021 by the D Language Foundation