Bug 23912 – Destructor disables scope inference

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2023-05-11T15:00:53Z
Last change time
2023-05-16T19:51:11Z
Keywords
pull, rejects-valid, safe
Assigned to
No Owner
Creator
Richard Cattermole

Comments

Comment #0 by alphaglosined — 2023-05-11T15:00:53Z
Adding a destructor to an otherwise DIP1000 scope aware struct stops scope automatic inference when used in an expression and passed to say a function. Known for frontend 2.102. Output with destructor: <source>(12): Error: scope variable `input` assigned to non-scope `Test(null)` ```d struct Test { string val; this(return scope string val) scope @safe { } ~this() scope @safe { } } void giver(scope string input) @safe { accepts(Test(input)); } void accepts(scope Test test) @safe { } ```
Comment #1 by dlang-bot — 2023-05-16T10:19:56Z
@RazvanN7 created dlang/dmd pull request #15239 "Fix Issue 23912 - Destructor disables scope inference" fixing this issue: - Fix Issue 23912 - Destructor disables scope inference https://github.com/dlang/dmd/pull/15239
Comment #2 by dlang-bot — 2023-05-16T19:51:11Z
dlang/dmd pull request #15239 "Fix Issue 23912 - Destructor disables scope inference" was merged into master: - 40853c826e70ae9ca5c46775ef944d2e8361a191 by RazvanN7: Fix Issue 23912 - Destructor disables scope inference https://github.com/dlang/dmd/pull/15239