Built-in sumtypes, case and noreturn: why block enders should be expressions.

Dukc ajieskola at gmail.com
Tue Oct 25 10:04:50 UTC 2022


On Monday, 24 October 2022 at 06:20:15 UTC, FeepingCreature wrote:
> But the  way that it *actually works* now, is that **all** 
> block enders, ie. `return`, `break` and `continue`, instead of 
> statements are just - expressions of type `bottom`.

You forgot the old good `goto` 😉.


> PS: hilariously, with this change the following is entirely 
> valid code:
>
> ```
> int foo() { return return return 3; }
> ```

Not any more hilariously than that this should maybe compile 
according to current rules:
```D
@safe void main()
{ throw throw throw new Exception("hello");
}
```

It does not though. The implementation does not currently convert 
the bottom type to `throwable`. If this is allowed, should it be 
allowed in `nothrow`? What about `@safe`? I tend to think that 
yes but not sure.


More information about the Digitalmars-d mailing list