This is interesting, if you compile it with:
dmd test.d
It works. If you compile it with:
dmd -inline test.d
It doesn't compile and dmd returns:
test.d(5): Error: function D main is a nested function and cannot be accessed
from array
import std.algorithm: map;
import std.array: array;
void main() {
int c;
array(map!((x){return c;})([1]));
}
I think this is a compiler bug, right (because I think it must not compile in
both cases or compile in both)?
Bye,
bearophile

This is interesting, if you compile it with:
dmd test.d
It works. If you compile it with:
dmd -inline test.d
It doesn't compile and dmd returns:
test.d(5): Error: function D main is a nested function and cannot be
accessed from array
import std.algorithm: map;
import std.array: array;
void main() {
int c;
array(map!((x){return c;})([1]));
}
I think this is a compiler bug, right (because I think it must not compile
in both cases or compile in both)?
Bye,
bearophile

Inlining should _never_ affect the compilability of a program. It should be
essentially invisible to programmer. It might be visible if you examined the
actual assembly or resultant binary, and hopefully -inline makes your program
faster, but what errors you do or don't get and the semantics of your program
should be identical. This is most definitely a bug.
- Jonathan M Davis

Inlining should _never_ affect the compilability of a program. It should be
essentially invisible to programmer. It might be visible if you examined the
actual assembly or resultant binary, and hopefully -inline makes your program
faster, but what errors you do or don't get and the semantics of your program
should be identical. This is most definitely a bug.