Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 13116 - Should not be able to return ref to 'this'
- Loading branch information
Showing
5 changed files
with
31 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,18 @@ | ||
// REQUIRED_ARGS: -dw | ||
|
||
// PERMUTE_ARGS: | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
compilable/deprecate14283.d(17): Deprecation: this is not an lvalue | ||
compilable/deprecate14283.d(18): Deprecation: super is not an lvalue | ||
--- | ||
*/ | ||
|
||
class C | ||
{ | ||
void bug() | ||
{ | ||
autoref(this); // suppress warning for auto ref | ||
autoref(super); // suppress warning for auto ref | ||
ref_(this); // still warns | ||
ref_(super); // still warns | ||
autoref(this); // 'auto ref' becomes non-ref parameter | ||
autoref(super); // 'auto ref' becomes non-ref parameter | ||
} | ||
} | ||
|
||
void autoref(T)(auto ref T t) {} | ||
void ref_(T)(ref T) {} | ||
void autoref(T)(auto ref T t) { static assert(__traits(isRef, t) == false); } |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag4596.d(15): Error: this is not an lvalue | ||
fail_compilation/diag4596.d(16): Error: 1 ? this : this is not an lvalue | ||
fail_compilation/diag4596.d(18): Error: super is not an lvalue | ||
fail_compilation/diag4596.d(19): Error: 1 ? super : super is not an lvalue | ||
--- | ||
*/ | ||
|
||
class NoGo4596 | ||
{ | ||
void fun() | ||
{ | ||
this = new NoGo4596; | ||
(1?this:this) = new NoGo4596; | ||
|
||
super = new Object; | ||
(1?super:super) = new Object; | ||
} | ||
} |
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