-
-
Notifications
You must be signed in to change notification settings - Fork 610
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6091 from WalterBright/fix16095
fix Issue 16095 - a delegate can mutate immutable data and break shar…
- Loading branch information
Showing
2 changed files
with
58 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /* | ||
| REQUIRED_ARGS: | ||
| PERMUTE_ARGS: | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/test16095.d(20): Error: shared method test16095.C.ping is not callable using a non-shared a | ||
| fail_compilation/test16095.d(30): Error: shared method test16095.S.ping is not callable using a non-shared *a | ||
| fail_compilation/test16095.d(43): Error: mutable method test16095.Foo.flip is not callable using a immutable foo | ||
| --- | ||
| */ | ||
| // https://issues.dlang.org/show_bug.cgi?id=16095 | ||
|
|
||
| class C | ||
| { | ||
| void ping() shared; | ||
| } | ||
|
|
||
| void test1(C a) | ||
| { | ||
| (&a.ping)(); // error | ||
| } | ||
|
|
||
| struct S | ||
| { | ||
| void ping() shared; | ||
| } | ||
|
|
||
| void test2(S* a) | ||
| { | ||
| (&a.ping)(); // error | ||
| } | ||
|
|
||
| struct Foo { | ||
| bool flag; | ||
| void flip() { | ||
| flag = true; | ||
| } | ||
| } | ||
|
|
||
| void test3() | ||
| { | ||
| immutable Foo foo; | ||
| (&foo.flip)(); // error | ||
| } |