-
-
Notifications
You must be signed in to change notification settings - Fork 606
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 #3761 from quickfur/issue13116
Issue 13116: should reject returning `this` from a ref class member function
- Loading branch information
Showing
5 changed files
with
39 additions
and
15 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,29 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail13116.d(13): Error: this is not an lvalue | ||
--- | ||
*/ | ||
struct S | ||
{ | ||
ref S notEvil() { return this; } // this should be accepted | ||
} | ||
class C | ||
{ | ||
ref C evil() { return this; } // this should be rejected | ||
} | ||
void main() | ||
{ | ||
} | ||
|
||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail13116.d(28): Error: super is not an lvalue | ||
--- | ||
*/ | ||
class Base { } | ||
class Derived : Base | ||
{ | ||
ref Base evil() { return super; } // should be rejected | ||
} |
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