proposed @noreturn attribute
Lurker via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 14 12:06:41 PDT 2017
On Friday, 14 July 2017 at 15:39:01 UTC, Guillaume Boucher wrote:
> Example 1: Polymorphism
>
> class Bird { void fly() { ... } };
> class Penguin : Bird { override void fly() @pragma(noreturn) {
> assert(0); } };
> class EvolvedPenguin : Penguin { override void fly() { ... } };
>
No matter how you look at it, this code should simply not be
allowed:
Bird bird = ...;
bird.fly(); // is this return or noreturn?
Penguin penguin = ...;
penguin.fly(); // is this return or noreturn?
In both cases, compiler cannot draw any conclusions about
return/noreturn and thus I believe such code should not be
allowed.
And if this is disallowed, a Bottom type would fit again.
More information about the Digitalmars-d
mailing list