Merge pull request #15826 from ntrel/method-mod

[dmd/func.d] Reword 'method not callable using a $mod object' error for constructors

Signed-off-by: Dennis <dkorpel@users.noreply.github.com>
Signed-off-by: Nicholas Wilson <thewilsonator@users.noreply.github.com>
Merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
This commit is contained in:
The Dlang Bot 2023-11-16 23:56:09 +01:00 committed by GitHub
commit 0dfc7bd891
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 3 deletions

View file

@ -1,7 +1,7 @@
/*
TEST_OUTPUT:
---
fail_compilation/fail217.d(22): Error: mutable method `fail217.Message.this` is not callable using a `immutable` object
fail_compilation/fail217.d(22): Error: mutable constructor `fail217.Message.this` cannot construct a `immutable` object
fail_compilation/fail217.d(13): Consider adding `const` or `inout` here
---
*/

View file

@ -0,0 +1,19 @@
/*
TEST_OUTPUT:
---
fail_compilation/immutable_ctor.d(18): Error: `immutable` copy constructor `immutable_ctor.S1.this` cannot construct a mutable object
---
*/
struct S1
{
this(ref const S1 s) immutable {
}
int i;
}
void main()
{
const(S1) s1;
S1 ms1 = s1;
}