-
-
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 #7553 from ibuclaw/issue18143
fix Issue 18143 - in/out contracts should be implicitly 'this' const merged-on-behalf-of: Mike Franklin <JinShil@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| TEST_OUTPUT: | ||
| --- | ||
| fail_compilation/fail18143.d(20): Error: variable fail18143.S.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(21): Error: variable fail18143.S.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(25): Error: variable fail18143.S.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(26): Error: variable fail18143.S.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(35): Error: variable fail18143.C.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(36): Error: variable fail18143.C.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(40): Error: variable fail18143.C.a cannot modify parameter 'this' in contract | ||
| fail_compilation/fail18143.d(41): Error: variable fail18143.C.a cannot modify parameter 'this' in contract | ||
| --- | ||
| */ | ||
|
|
||
| struct S | ||
| { | ||
| int a; | ||
|
|
||
| this(int n) | ||
| in { a = n; } // error, modifying this.a in contract | ||
| out { a = n; } // error, modifying this.a in contract | ||
| do { } | ||
|
|
||
| void foo(int n) | ||
| in { a = n; } // error, modifying this.a in contract | ||
| out { a = n; } // error, modifying this.a in contract | ||
| do { } | ||
| } | ||
|
|
||
| class C | ||
| { | ||
| int a; | ||
|
|
||
| this(int n) | ||
| in { a = n; } // error, modifying this.a in contract | ||
| out { a = n; } // error, modifying this.a in contract | ||
| do { } | ||
|
|
||
| void foo(int n) | ||
| in { a = n; } // error, modifying this.a in contract | ||
| out { a = n; } // error, modifying this.a in contract | ||
| do { } | ||
| } |