digitalmars.D.bugs - [Issue 23306] New: disable new() ought not disable `scope A = new A`
- d-bugmail puremagic.com (33/33) Aug 26 2022 https://issues.dlang.org/show_bug.cgi?id=23306
https://issues.dlang.org/show_bug.cgi?id=23306 Issue ID: 23306 Summary: disable new() ought not disable `scope A = new A` Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: destructionator gmail.com disable new can be used to disable the `new` operator on a thing so it isn't accidentally GC managed, which is liable to cause trouble with destructor/finalizer confusion. But it currently disables scope too: ``` class A { disable new(); } void main() { scope A a = new A(); } ``` scopeclass.d(6): Error: cannot allocate `class A` with `new` because it is annotated with ` disable new()` The purpose of disabling `new` is not the presence of the keyword per se, it has more to do with lifetime management. Like I said, it is about a destructor that needs to be called in a particular way every time I use it. `scope` solves this. So I propose that `scope x = new` be exempt from the ` disable new` check. --
Aug 26 2022