Skip to content

Commit

Permalink
Merge pull request #4399 from 9rnsr/fix14163
Browse files Browse the repository at this point in the history
Issue 14163 - No line number for error with disabled class constructor
  • Loading branch information
yebblies committed Feb 10, 2015
2 parents 6d90002 + 5a38707 commit d957c64
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/func.c
Expand Up @@ -1640,10 +1640,15 @@ void FuncDeclaration::semantic3(Scope *sc)
sc2->callSuper = 0;

// Insert implicit super() at start of fbody
if (!resolveFuncCall(Loc(), sc2, cd->baseClass->ctor, NULL, NULL, NULL, 1))
FuncDeclaration *fd = resolveFuncCall(Loc(), sc2, cd->baseClass->ctor, NULL, NULL, NULL, 1);
if (!fd)
{
error("no match for implicit super() call in constructor");
}
else if (fd->storage_class & STCdisable)
{
error("cannot call super() implicitly because it is annotated with @disable");
}
else
{
Expression *e1 = new SuperExp(Loc());
Expand Down
19 changes: 19 additions & 0 deletions test/fail_compilation/diag14163.d
@@ -0,0 +1,19 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag14163.d(16): Error: constructor diag14163.Bar.this cannot call super() implicitly because it is annotated with @disable
---
*/

class Foo
{
@disable this();
}

class Bar : Foo
{
@disable this();
this(int i) {}
}

void main() {}

0 comments on commit d957c64

Please sign in to comment.