Skip to content

Commit

Permalink
fix Issue 13498 - Return type is not checked in function template
Browse files Browse the repository at this point in the history
  • Loading branch information
9rnsr committed Sep 20, 2014
1 parent c83986a commit b158adb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/func.c
Expand Up @@ -1841,8 +1841,7 @@ void FuncDeclaration::semantic3(Scope *sc)
else if (exp->type->wildOf()->implicitConvTo(tret))
exp = exp->castTo(sc2, exp->type->wildOf());
}
else
exp = exp->implicitCastTo(sc2, tret);
exp = exp->implicitCastTo(sc2, tret);

if (f->isref)
{
Expand Down
17 changes: 17 additions & 0 deletions test/fail_compilation/fail13498.d
@@ -0,0 +1,17 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail13498.d(11): Error: cannot implicitly convert expression ("foo") of type string to int
fail_compilation/fail13498.d(16): Error: template instance fail13498.foo!() error instantiating
---
*/

int foo()()
{
return "foo"; // should fail as well
}

void main()
{
foo();
}

0 comments on commit b158adb

Please sign in to comment.