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 #9467 from RazvanN7/Issue_19731
Fix Issue 19731 - auto struct methods whose address is taken don't test invariants merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
- Loading branch information
Showing
2 changed files
with
93 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// PERMUTE_ARGS: | ||
struct Foo | ||
{ | ||
Object obj_; | ||
|
||
invariant (obj_ !is null); | ||
|
||
auto obj7() | ||
{ | ||
return this.obj_; | ||
} | ||
|
||
enum compiles = __traits(compiles, &Foo.init.obj7); | ||
} | ||
|
||
class Foo2 | ||
{ | ||
Object obj_; | ||
|
||
invariant (obj_ !is null); | ||
|
||
final auto obj7() | ||
{ | ||
return this.obj_; | ||
} | ||
|
||
enum compiles = __traits(compiles, &Foo.init.obj7); | ||
} | ||
|
||
void main() | ||
{ | ||
import core.exception : AssertError; | ||
Foo foo = Foo(); | ||
Foo2 foo2 = new Foo2(); | ||
|
||
try | ||
{ | ||
foo.obj7.toString(); | ||
} | ||
catch(AssertError) | ||
{ | ||
try | ||
{ | ||
foo2.obj7.toString(); | ||
} | ||
catch(AssertError) | ||
{ | ||
return; | ||
} | ||
assert(0); | ||
} | ||
assert(0); | ||
} |