[Issue 20149] [DIP1000] temp returned from constructor call not checked for scope problems
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Sep 9 09:20:35 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=20149
--- Comment #16 from Mike Franklin <slavo5150 at yahoo.com> ---
(In reply to Walter Bright from comment #15)
> Please pare the example code down to the minimum.
This is the most minimal example I know how to make to illustrate the issue:
---
@safe:
struct ScopeBuffer
{
this(char[4] init)
{
this.buf = init;
}
inout(char)[] opSlice(size_t lower, size_t upper) inout
{
return buf[lower .. upper];
}
char[4] buf;
}
char[] fun()
{
char[4] buf = "abcd";
auto sb = ScopeBuffer(buf);
return sb[0..2];
}
void main()
{
auto s = fun();
}
---
> In fact, the original
> issue was fixed. If there is another issue, please leave this one closed,
> and open a new issue for the other issue.
>
> I.e. one issue == one fix
The example above is the original issue and is related to how `inout` infers
`return`.
The issue you added was a new, unrelated, issue related to how constructors are
checked for scope issues. I fixed that issue in
https://github.com/dlang/dmd/pull/10402.
If we wanted one issue == one fix, we should have made a new issue for the
check on constructors, but we're past that now.
The original issue remains, and I've submitted a fix to
https://github.com/dlang/dmd/pull/10390
--
More information about the Digitalmars-d-bugs
mailing list