Enhancements can enable memory-safe reference counting
tsbockman
thomas.bockman at gmail.com
Fri Nov 26 04:37:16 UTC 2021
On Saturday, 20 November 2021 at 08:58:15 UTC, Imperatorn wrote:
> On Saturday, 20 November 2021 at 08:08:44 UTC, tsbockman wrote:
>> "Template breaks return annotation for class reference
>> returned by struct method"
>> https://issues.dlang.org/show_bug.cgi?id=22528
>
> Nice, this one should not be that hard to fix.
>
> Does someone have time to look at it?
Dennis [partially explained the cause of the
problem](https://issues.dlang.org/show_bug.cgi?id=22528#c1), and
suggested a workaround. After some experimentation, I found a
more general form of the workaround that eliminates all "ACCEPTS
INVALID" errors in my earlier test code.
Including this line at the beginning of each offending `return`
member function will fix them:
```D
typeof(&this) pseudoEscape = &this ; // DMD Issue #22528
workaround.
```
With this change to `Unique`, all of the tests from my first post
in this thread now pass except for `e: REJECTS VALID: scope int**
= &(return ref int*)`. As a result, the `borrow` `mixin template`
is no longer needed at all. **Progress!**
The hackish, possibly fragile nature of the workaround, and the
[destructor
issue](https://issues.dlang.org/show_bug.cgi?id=21981) still make
my solution unsuitable for the standard library for now, though.
More information about the Digitalmars-d
mailing list