Fix Issue 23914 - auto ref resolution on return value prevented by noreturn (#15240)

This commit is contained in:
Razvan Nitu 2023-05-19 10:54:22 +03:00 committed by GitHub
parent 923bc30a56
commit a19be2d341
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 5 deletions

View file

@ -2732,7 +2732,8 @@ Statement statementSemanticVisit(Statement s, Scope* sc)
tbret = tret.toBasetype();
}
if (inferRef) // deduce 'auto ref'
// https://issues.dlang.org/show_bug.cgi?id=23914
if (inferRef && !resType.isTypeNoreturn()) // deduce 'auto ref'
tf.isref = false;
if (tbret.ty != Tvoid && !resType.isTypeNoreturn()) // if non-void return

View file

@ -91,8 +91,8 @@ auto ref forwardOrExit(ref int num)
static assert( is(typeof(forwardOrExit(global)) == int));
// // Must not infer ref due to the noreturn rvalue
static assert(!is(typeof(&forwardOrExit(global))));
// Noreturn types do not affect `auto ref` deduction
static assert(is(typeof(&forwardOrExit(global))));
auto ref forwardOrExit2(ref int num)
{
@ -104,8 +104,8 @@ auto ref forwardOrExit2(ref int num)
static assert( is(typeof(forwardOrExit2(global)) == int));
// // Must not infer ref due to the noreturn rvalue
static assert(!is(typeof(&forwardOrExit2(global))));
// Noreturn types do not affect `auto ref` deduction
static assert(is(typeof(&forwardOrExit2(global))));
/*****************************************************************************/