Skip to content

Commit

Permalink
Merge pull request #9466 from RazvanN7/Issue_19744
Browse files Browse the repository at this point in the history
Fix Issue 19744 - Confusing error message when annotating a non-memberr function with return
merged-on-behalf-of: Jacob Carlborg <jacob-carlborg@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Mar 19, 2019
2 parents 4edae68 + 1988c5d commit b0c7f7a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dmd/dsymbolsem.d
Expand Up @@ -3139,7 +3139,10 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor
/* Non-static nested functions have a hidden 'this' pointer to which
* the 'return' applies
*/
funcdecl.error("`static` member has no `this` to which `return` can apply");
if (sc.scopesym && sc.scopesym.isAggregateDeclaration())
funcdecl.error("`static` member has no `this` to which `return` can apply");
else
error(funcdecl.loc, "Top-level function `%s` has no `this` to which `return` can apply", funcdecl.toChars());
}

if (funcdecl.isAbstract() && !funcdecl.isVirtual())
Expand Down
11 changes: 11 additions & 0 deletions test/fail_compilation/fail19744.d
@@ -0,0 +1,11 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail19744.d(8): Error: Top-level function `test` has no `this` to which `return` can apply
---
*/

int* test(return scope int* n) return
{
return n;
}

0 comments on commit b0c7f7a

Please sign in to comment.