Bug 22364 – Unreachable warning for collectException[Msg] with noreturn value

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-10-07T19:35:57Z
Last change time
2021-10-08T11:49:55Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel

Comments

Comment #0 by moonlightsentinel — 2021-10-07T19:35:57Z
Passing a noreturn value to either collectException or collectExceptionMsg triggers the "statement is not reachable" warning for the additional return statement when no exception is thrown. Examples: noreturn foo() { throw new Exception(""); } collectException!(Exception, noreturn)(foo()); noreturn n; collectException!(Exception, noreturn)(foo(), n); collectExceptionMsg!(Exception, noreturn)(foo());
Comment #1 by dlang-bot — 2021-10-07T19:39:57Z
@MoonlightSentinel created dlang/phobos pull request #8264 "Fix 22364 - Omit unreachable `return` in collectException[Msg]..." fixing this issue: - Fix 22364 - Omit unreachable `return` in collectException[Msg]... ...when instantiated with `noreturn`. DMD is able to determine that a lazy `noreturn` expression will interrupt the normal control flow (throw / halt / ...) s.t. it never reaches the `return`. https://github.com/dlang/phobos/pull/8264
Comment #2 by dlang-bot — 2021-10-08T11:49:55Z
dlang/phobos pull request #8264 "Fix 22364 - Omit unreachable `return` in collectException[Msg]..." was merged into master: - fac622655b0b904b717bed7e760ced58ca269315 by MoonlightSentinel: Fix 22364 - Omit unreachable `return` in collectException[Msg]... ...when instantiated with `noreturn`. DMD is able to determine that a lazy `noreturn` expression will interrupt the normal control flow (throw / halt / ...) s.t. it never reaches the `return`. https://github.com/dlang/phobos/pull/8264