From 837bbc2dfa98b413694352a2ce8a191bb706aa34 Mon Sep 17 00:00:00 2001 From: RazvanN7 Date: Thu, 22 Nov 2018 15:48:30 +0200 Subject: [PATCH] Fix Issue 19419 - [REG2.080.1] @disabled this() will print wrong error if calling non-default constructor with wrong parameters --- src/dmd/func.d | 3 ++- test/fail_compilation/fail19419.d | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 test/fail_compilation/fail19419.d diff --git a/src/dmd/func.d b/src/dmd/func.d index db71082713c7..d27eaac3e72a 100644 --- a/src/dmd/func.d +++ b/src/dmd/func.d @@ -2749,7 +2749,8 @@ extern (C++) FuncDeclaration resolveFuncCall(const ref Loc loc, Scope* sc, Dsymb { assert(fd); - if (fd.checkDisabled(loc, sc)) + // remove when deprecation period of class allocators and deallocators is over + if (fd.isNewDeclaration() && fd.checkDisabled(loc, sc)) return null; bool hasOverloads = fd.overnext !is null; diff --git a/test/fail_compilation/fail19419.d b/test/fail_compilation/fail19419.d new file mode 100644 index 000000000000..f25531fca655 --- /dev/null +++ b/test/fail_compilation/fail19419.d @@ -0,0 +1,21 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/fail19419.d(20): Error: none of the overloads of `this` are callable using argument types `(int)`, candidates are: +fail_compilation/fail19419.d(12): `fail19419.B.this()` +fail_compilation/fail19419.d(14): `fail19419.B.this(string s)` +--- +*/ + +struct B +{ + @disable this(); + + this(string s) + {} +} + +void main() +{ + auto b = B(3); +}