mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
29 lines
495 B
D
29 lines
495 B
D
/*
|
|
TEST_OUTPUT:
|
|
---
|
|
fail_compilation/fail13336a.d(28): Error: cannot modify expression `choose(true)` because it is not an lvalue
|
|
---
|
|
*/
|
|
|
|
class Animal {}
|
|
class Cat : Animal {}
|
|
class Dog : Animal {}
|
|
|
|
Animal animal;
|
|
Cat cat;
|
|
|
|
auto ref choose(bool f)
|
|
{
|
|
if (f)
|
|
return cat;
|
|
else
|
|
return animal;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
//pragma(msg, typeof(&choose));
|
|
static assert(is(typeof(&choose) == Animal function(bool) nothrow @nogc @safe)); // pass
|
|
|
|
choose(true) = new Dog();
|
|
}
|