Should this compile?
Timon Gehr via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 26 12:55:52 PDT 2015
On 08/25/2015 08:29 PM, Vladimir Panteleev wrote:
>
> I think this is a bug, but is easily worked around with:
>
> auto test(string a) {
> return .test(a, "b");
> }
>
> I suspect that the reason the error occurs, is that the auto return type
> automatically rewrites the function declaration into an eponymous
> template declaration. ...
No true. In fact, doing so manually works around the problem. :o)
This compiles and runs:
import std.stdio;
import std.range : chain;
auto test()(string a) {
return test(a,"b");
}
auto test(string a,string b) {
return chain(a,b);
}
void main() {
writeln(test("a"));
}
More information about the Digitalmars-d-learn
mailing list