Bug 22472 – Invalid error message for `void` return from non-`void` functions
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-11-03T12:02:58Z
Last change time
2021-11-08T20:45:46Z
Keywords
pull
Assigned to
No Owner
Creator
moonlightsentinel
Comments
Comment #0 by moonlightsentinel — 2021-11-03T12:02:58Z
======================================================
void doStuff();
int foo()
{
return doStuff();
}
======================================================
Error: `return` expression expected
The error message indicates that there was no expression, despite there being a `void` one.
The previous message was more useful but changed after 2.066.0:
Error: cannot implicitly convert expression (doStuff()) of type void to int
Comment #1 by dlang-bot — 2021-11-03T12:06:25Z
@MoonlightSentinel created dlang/dmd pull request #13258 "Fix 22472 - Correct error message for invalid `void` return" fixing this issue:
- Fix 22472 - Correct error message for invalid `void` return
The old error message (`return expression expected`) ignored the
possibility that `void` and `noreturn` expressions are moved into `e0`.
This caused misleading error messages when errors are detected after
the move, claiming that the expression found in the source code is
missing.
Small improvement to #13135 because this is more likely to happen for
`noreturn` functions.
https://github.com/dlang/dmd/pull/13258
Comment #2 by dlang-bot — 2021-11-03T23:45:51Z
dlang/dmd pull request #13258 "Fix 22472 - Correct error message for invalid `void` return" was merged into stable:
- 2b5dce74113a2be5555d2f843a9cf4e5f5224c3b by MoonlightSentinel:
Fix 22472 - Correct error message for invalid `void` return
The old error message (`return expression expected`) ignored the
possibility that `void` and `noreturn` expressions are moved into `e0`.
This caused misleading error messages when errors are detected after
the move, claiming that the expression found in the source code is
missing.
Small improvement to #13135 because this is more likely to happen for
`noreturn` functions.
https://github.com/dlang/dmd/pull/13258
Comment #3 by dlang-bot — 2021-11-08T20:45:46Z
dlang/dmd pull request #13279 "Merge `stable` into `master`" was merged into master:
- b1429054c103b4be759d6c9ca671b5268bdaa0de by MoonlightSentinel:
Fix 22472 - Correct error message for invalid `void` return
The old error message (`return expression expected`) ignored the
possibility that `void` and `noreturn` expressions are moved into `e0`.
This caused misleading error messages when errors are detected after
the move, claiming that the expression found in the source code is
missing.
Small improvement to #13135 because this is more likely to happen for
`noreturn` functions.
https://github.com/dlang/dmd/pull/13279