-
-
Notifications
You must be signed in to change notification settings - Fork 609
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 #6839 from WalterBright/fix17450
fix Issue 17450 - escaping delegate context pointer not detected for … merged-on-behalf-of: Daniel Murphy <yebblies@gmail.com>
- Loading branch information
Showing
4 changed files
with
73 additions
and
8 deletions.
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
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,58 @@ | ||
| /* | ||
| REQUIRED_ARGS: -dip1000 -dip25 | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/test17450.d(15): Error: escaping reference to local variable s | ||
| fail_compilation/test17450.d(18): Error: escaping reference to local variable this | ||
| --- | ||
| */ | ||
| // https://issues.dlang.org/show_bug.cgi?id=17450 | ||
|
|
||
| alias dg_t = void delegate(); | ||
|
|
||
| struct S { | ||
| @safe dg_t foo1(ref S s) { | ||
| return &s.bar; | ||
| } | ||
| @safe dg_t foo2() { | ||
| return &bar; | ||
| } | ||
|
|
||
| @safe dg_t foo3(return ref S s) { | ||
| return &s.bar; | ||
| } | ||
| @safe dg_t foo4() return { | ||
| return &bar; | ||
| } | ||
|
|
||
| @safe void bar(); | ||
| } | ||
|
|
||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/test17450.d(103): Error: scope variable c may not be returned | ||
| fail_compilation/test17450.d(106): Error: scope variable this may not be returned | ||
| --- | ||
| */ | ||
| // https://issues.dlang.org/show_bug.cgi?id=17450 | ||
|
|
||
| #line 100 | ||
|
|
||
| class C { | ||
| @safe dg_t foo1(scope C c) { | ||
| return &c.bar; | ||
| } | ||
| @safe dg_t foo2() scope { | ||
| return &bar; | ||
| } | ||
|
|
||
| @safe dg_t foo3(return scope C c) { | ||
| return &c.bar; | ||
| } | ||
| @safe dg_t foo4() return scope { | ||
| return &bar; | ||
| } | ||
|
|
||
| @safe void bar(); | ||
| } |