Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/dmd/typesem.d
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor

if (tf.isreturn && !tf.isref && !tf.next.hasPointers())
{
mtype.error(loc, "function type `%s` has `return` but does not return any indirections", tf.toChars());
tf.isreturn = false;
}
}

Expand Down Expand Up @@ -964,9 +964,7 @@ private extern (C++) final class TypeSemanticVisitor : Visitor
}
else if (tf.next && !tf.next.hasPointers())
{
mtype.error(loc, "parameter `%s` is `return` but function does not return any indirections",
fparam.ident ? fparam.ident.toChars() : "");
errors = true;
fparam.storageClass &= ~STC.return_; // https://issues.dlang.org/show_bug.cgi?id=18963
}
}
}
Expand Down
14 changes: 13 additions & 1 deletion test/fail_compilation/test16228.d
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* REQUIRED_ARGS: -dip25
TEST_OUTPUT:
---
fail_compilation/test16228.d(22): Error: function type `int() return` has `return` but does not return any indirections
fail_compilation/test16228.d(23): Error: function `test16228.S.bar` `static` member has no `this` to which `return` can apply
---
*/




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

int* wrap ( return ref int input )
Expand All @@ -22,3 +22,15 @@ struct S
int foo() return { return 3; }
static ref int bar() return { return x; }
}


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

T Identity(T)(return T t) { return t; }

void bar(int i, void* p)
{
Identity(p);
Identity(i);
}