[Issue 17961] std.uni does not compile with -unittest -dip1000

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 10 09:40:52 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=17961

Carsten Blüggel <chilli at posteo.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chilli at posteo.net

--- Comment #7 from Carsten Blüggel <chilli at posteo.net> ---
Although -dip1000 is not ready, it's complaint seems to be justified in at
least 1 of 2 spots here:
The complaints originate in the function immediately preceding the reported
error line:  ref intersect()(dchar ch)
(1) There are 2 assignments to this: this = This.init...
that raise the error, IMO legitimately: reference to local variable __tmp...
assigned to non-scope parameter this.
This could be calmed down using instead: data.length(0); I hope it's an
equivalent for This.init in this case.
(2) The other one (same error msg) stems from this.byInterval in the foreach
loop and seems to be questionable.

In the end, this works with -dip1000 enabled:

    ref intersect()(dchar ch)
    {
        scope arr = data;
        foreach (i; Intervals!(typeof(data))(arr))
            if (i.a <= ch && ch < i.b)
            {
                data.length(0);
                return this.add(ch, ch+1);
            }
        data.length(0);
        return this;
    }

If there are no objections, I'll file a PR Fix issue 17961 - ...

--


More information about the Digitalmars-d-bugs mailing list