Thread overview
[Issue 24117] noreturn can be used as expression
Aug 28, 2023
Nick Treleaven
Aug 28, 2023
Dlang Bot
Aug 28, 2023
Basile-z
Aug 30, 2023
Dlang Bot
Aug 30, 2023
Nick Treleaven
Aug 31, 2023
Dlang Bot
August 28, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #1 from Nick Treleaven <nick@geany.org> ---
This code:

    auto e = noreturn + 1;

Gets lowered to:

        int e = 1;

Also, `cast(int) E.illegal` is 0.

--
August 28, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel created dlang/dmd pull request #15561 "Fix Issue 24117 - noreturn can be used as expression" fixing this issue:

- Fix Issue 24117 - noreturn can be used as expression

https://github.com/dlang/dmd/pull/15561

--
August 28, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
Example 2 was about the member initializer

Also if it's set to 0, then this becomes a problem because it's not expected to have two members of the same value, e.g

```d
enum E {e0 = 0, e1 = 1, illegal = noreturn}
```

Otherwise I have a 3rd example:

```d
void main()
{
    foreach (const i; 0 .. noreturn){}
}
```

--
August 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@ntrel created dlang/dmd pull request #15562 "Fix Issue 24117 - noreturn can be used as expression" fixing this issue:

- Fix Issue 24117 - noreturn can be used as expression

https://github.com/dlang/dmd/pull/15562

--
August 30, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

--- Comment #5 from Nick Treleaven <nick@geany.org> ---
> enum E {e0 = 0, e1 = 1, illegal = noreturn}

>     foreach (const i; 0 .. noreturn){}

I made a new fix that is more precise which does reject the 2 above and should cover all cases.

--
August 31, 2023
https://issues.dlang.org/show_bug.cgi?id=24117

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #15562 "Fix Issue 24117 - noreturn can be used as expression" was merged into master:

- 46f1225eaeaf4332f5769ce5b1e3853d88ede527 by Nick Treleaven:
  Fix Issue 24117 - noreturn can be used as expression

https://github.com/dlang/dmd/pull/15562

--