auto limitation?
bearophile
bearophileHUGS at lycos.com
Tue Sep 11 14:13:28 PDT 2012
Namespace:
> I have this code, but it works not as expected:
> http://dpaste.dzfl.pl/6ce5b4dd
I suggest to file a bug:
auto foo(bool b) {
final switch (b) {
case true:
return 10;
case false:
return 20.0;
}
}
void main() {
import std.stdio: writeln;
writeln(foo(true));
writeln(foo(false));
}
The acceptable results are a compile-time error for type
mismatch, or a conversion of both literals to double. Probably
the second is better. But a silent bit-level cast is not
acceptable.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list