[Issue 22004] New: [REG2.097] Error: mismatched function return type inference of `void` and `noreturn`

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jun 8 09:45:00 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22004

          Issue ID: 22004
           Summary: [REG2.097] Error: mismatched function return type
                    inference of `void` and `noreturn`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dlang-bugzilla at thecybershadow.net

/////////////////////////// test.d ///////////////////////////
alias fun = _ => {}();
alias gun = _ => assert(0);
auto bun(bool b) { if (b) return gun(0); else return fun(0); }
//////////////////////////////////////////////////////////////

test.d(3): Error: mismatched function return type inference of `void` and
`noreturn`

The return type of bun should be void, as in fun's.

If the gun and fun calls are swapped, the error message changes:

test.d(3): Error: cannot return non-void from `void` function

But, "returning" a "noreturn" value should be allowed from a void function.

Worked in 2.096.0.

--


More information about the Digitalmars-d-bugs mailing list