Skip to content

Commit

Permalink
Fixes Issue 10099 - Better diagnostic for a disabled default construc…
Browse files Browse the repository at this point in the history
…tor.
  • Loading branch information
AndrejMitrovic committed Sep 19, 2013
1 parent a5086fa commit 1ecb452
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ void VarDeclaration::semantic(Scope *sc)
else if (storage_class & STCparameter)
;
else
error("initializer required for type %s", type->toChars());
error("default construction is disabled for type %s", type->toChars());
}
}
#endif
Expand Down
16 changes: 16 additions & 0 deletions test/fail_compilation/diag10099.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
TEST_OUTPUT:
---
fail_compilation/diag10099.d(15): Error: variable diag10099.main.s default construction is disabled for type S
---
*/

struct S
{
@disable this();
}

void main()
{
S s;
}
4 changes: 2 additions & 2 deletions test/fail_compilation/fail10102.d
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail10102.d(48): Error: variable fail10102.main.m initializer required for type NotNull!(int*)
fail_compilation/fail10102.d(49): Error: variable fail10102.main.a initializer required for type NotNull!(int*)[3]
fail_compilation/fail10102.d(48): Error: variable fail10102.main.m default construction is disabled for type NotNull!(int*)
fail_compilation/fail10102.d(49): Error: variable fail10102.main.a default construction is disabled for type NotNull!(int*)[3]
fail_compilation/fail10102.d(50): Error: default construction is disabled for type NotNull!(int*)
fail_compilation/fail10102.d(51): Error: field S.m must be initialized because it has no default constructor
---
Expand Down

0 comments on commit 1ecb452

Please sign in to comment.