-
-
Notifications
You must be signed in to change notification settings - Fork 676
Fix Issue 18295 - scope class check too conservative under -dip1000
#7771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // REQUIRED_ARGS: -dip1000 | ||
|
|
||
| // https://issues.dlang.org/show_bug.cgi?id=18295 | ||
|
|
||
| // See test/fail_compilation/test18295.d for the non-`-dip1000` version` | ||
|
|
||
| scope class C { int i; } // Notice the use of `scope` here | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not irrelevant, and in fact is the whole point of this PR. Prior to this PR, due to the |
||
|
|
||
| C increment(scope return C c) @safe // Prior to the fix for 18295 an error would be emitted here | ||
| { // which is too conservative | ||
| c.i++; | ||
| return c; | ||
| } | ||
|
|
||
| void main() @safe | ||
| { | ||
| scope C c = new C(); | ||
| c.increment(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without
@safe:there are no scope checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
@safeattributes