[Issue 13336] auto ref return deduced to be ref despite return value coercion
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Aug 19 14:59:29 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13336
--- Comment #1 from Peter Alexander <peter.alexander.au at gmail.com> ---
You can break the type system using this:
class Animal {}
class Cat : Animal {}
class Dog : Animal {}
Animal animal;
Cat cat;
auto ref choose()
{
return cat;
return animal;
}
void main()
{
import std.stdio;
choose() = new Dog();
writeln("cat is a ", typeid(cat));
}
Prints "cat is a Dog"
--
More information about the Digitalmars-d-bugs
mailing list