Library and site D examples
Steven Schveighoffer
schveiguy at gmail.com
Thu Feb 2 14:40:58 UTC 2023
On 1/28/23 7:03 PM, Karmello wrote:
> struct x
> {
> static:
> auto a = iota(1,1000).map!(i => round(log(i))).take(30).array;
> }
This is a bug in the compiler. Change your function to not be a
templated lambda, and it works:
```d
struct x
{
static:
auto a = iota(1,1000).map!((int i) => round(log(i))).take(30).array;
}
```
It can be reduced to:
```d
struct x
{
static:
auto a = [1,2,3].map!(i => i); // fails
auto b = [1,2,3].map!((int i) => i); // works
}
```
From testing on run.dlang.io, this hasn't worked all the way back to 2.060.
There is already a bug report on this:
https://issues.dlang.org/show_bug.cgi?id=20077
-Steve
More information about the Digitalmars-d
mailing list