-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 11909 - Struct members and static arrays break pure function es…
…cape analysis (immutability violation).
- Loading branch information
1 parent
4bfca03
commit fa6898c
Showing
3 changed files
with
42 additions
and
13 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,15 @@ | ||
| struct Data | ||
| { | ||
| char[256] buffer; | ||
| @property const(char)[] filename() const pure nothrow | ||
| { | ||
| return buffer[]; | ||
| } | ||
| } | ||
|
|
||
| void main() | ||
| { | ||
| Data d; | ||
| string f = d.filename; | ||
| d.buffer[0] = 'a'; | ||
| } |
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,22 @@ | ||
| struct Data2 | ||
| { | ||
| char buffer; | ||
| } | ||
|
|
||
| @property const(char)[] filename(const ref Data2 d) pure nothrow | ||
| { | ||
| return (&d.buffer)[0 .. 1]; | ||
| } | ||
|
|
||
| @property const(char)[] filename2(const Data2* d) pure nothrow | ||
| { | ||
| return (&d.buffer)[0 .. 1]; | ||
| } | ||
|
|
||
| void main() | ||
| { | ||
| Data2 d; | ||
| string f = d.filename; | ||
| string g = (&d).filename2; | ||
| d.buffer = 'a'; | ||
| } |