mirror of
https://github.com/dlang/dmd.git
synced 2025-04-25 20:50:41 +03:00
This commit is contained in:
parent
92f9f997ba
commit
cf2674f689
3 changed files with 30 additions and 3 deletions
|
@ -1713,8 +1713,14 @@ FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s,
|
|||
OutBuffer buf;
|
||||
buf.argExpTypesToCBuffer(fargs);
|
||||
if (fd.isCtorDeclaration())
|
||||
.error(loc, "none of the overloads of `%s` can construct a %sobject with argument types `(%s)`",
|
||||
fd.toChars(), thisBuf.peekChars(), buf.peekChars());
|
||||
{
|
||||
if (tthis.mod & MODFlags.immutable_)
|
||||
.error(loc, "none of the overloads of `%s` can construct an immutable object with argument types `(%s)`. Expected `immutable(%s)`",
|
||||
fd.toChars(), buf.peekChars(), buf.peekChars());
|
||||
else
|
||||
.error(loc, "none of the overloads of `%s` can construct a %sobject with argument types `(%s)`",
|
||||
fd.toChars(), thisBuf.peekChars(), buf.peekChars());
|
||||
}
|
||||
else
|
||||
.error(loc, "none of the overloads of `%s` are callable using a %sobject with argument types `(%s)`",
|
||||
fd.toChars(), thisBuf.peekChars(), buf.peekChars());
|
||||
|
|
21
compiler/test/fail_compilation/fix20075.d
Normal file
21
compiler/test/fail_compilation/fix20075.d
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
TEST_OUTPUT:
|
||||
---
|
||||
fail_compilation/fix20075.d(15): Error: none of the overloads of `this` can construct an immutable object with argument types `(int*)`. Expected `immutable(int*)`
|
||||
fail_compilation/fix20075.d(11): Candidate is: `fix20075.Foo.this(immutable(int*) a) immutable`
|
||||
---
|
||||
*/
|
||||
|
||||
struct Foo {
|
||||
@disable this();
|
||||
immutable this(immutable int* a) {}
|
||||
}
|
||||
|
||||
immutable(Foo) getFoo(int* a) {
|
||||
return immutable Foo(a);
|
||||
}
|
||||
|
||||
void main() {
|
||||
int x;
|
||||
auto foo = getFoo(&x);
|
||||
}
|
|
@ -5,7 +5,7 @@ TEST_OUTPUT:
|
|||
---
|
||||
fail_compilation/testrvaluecpctor.d(16): Error: cannot define both an rvalue constructor and a copy constructor for `struct Foo`
|
||||
fail_compilation/testrvaluecpctor.d(24): Template instance `testrvaluecpctor.Foo!int.Foo.__ctor!(immutable(Foo!int), immutable(Foo!int))` creates an rvalue constructor for `struct Foo`
|
||||
fail_compilation/testrvaluecpctor.d(24): Error: none of the overloads of `this` can construct a `immutable` object with argument types `(immutable(Foo!int))`
|
||||
fail_compilation/testrvaluecpctor.d(24): Error: none of the overloads of `this` can construct an immutable object with argument types `(immutable(Foo!int))`. Expected `immutable(immutable(Foo!int))`
|
||||
fail_compilation/testrvaluecpctor.d(18): Candidates are: `testrvaluecpctor.Foo!int.Foo.this(ref scope Foo!int rhs)`
|
||||
fail_compilation/testrvaluecpctor.d(16): `this(Rhs, this This)(scope Rhs rhs)`
|
||||
---
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue