Bug 18295 – [Scope][dip1000] `scope class` check too conservative under -dip1000

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-24T20:50:42Z
Last change time
2021-06-10T18:50:53Z
Keywords
pull, rejects-valid, safe
Assigned to
No Owner
Creator
Mike Franklin

Comments

Comment #0 by slavo5150 — 2018-01-24T20:50:42Z
In practice, the following two examples are no different: Example 1: Compile with -dip1000 -------------------------------- scope class C { int i; } // Notice the use of `scope` here C increment(C c) // Error: functions cannot return scope C { c.i++; return c; } void main() { scope C c = new C(); c.increment(); } Example 2: Compile with -dip1000 -------------------------------- class C { int i; } // Notice the absence of `scope` here C increment(C c) // OK: no error { c.i++; return c; } void main() { scope C c = new C(); c.increment(); } So, I argue that with the introduction of the -dip1000 compiler switch it is no longer necessary conservatively check the function declaration for `scope class`es. Rather a `scope class` should simply require variable instantiations to be attributed with `scope`, and let -dip1000 do the rest.
Comment #1 by slavo5150 — 2018-01-24T21:21:09Z
Comment #2 by bugzilla — 2018-03-20T06:48:00Z
I propose abandoning `scope class C { ... }` altogether. See https://github.com/dlang/dlang.org/pull/2027
Comment #3 by dkorpel — 2021-06-10T18:50:53Z
As stated in https://github.com/dlang/dmd/pull/7771#issuecomment-374497794 > instead of fixing this issue (Issue 18295), I'll move ahead deprecating > scope-as-a-type-modifier, which will eventually make the issue irrelevant. > Closing Considering https://github.com/dlang/dlang.org/pull/2027 has been merged, closing as WONTFIX