From the newsgroup: https://forum.dlang.org/post/[email protected]
```D
// REQUIRED_ARGS: -preview=dip1000
@safe:
struct B()
{
int* a;
C!() c;
}
class C()
{
C!() foo(int* a)
{
return foo2(a);
}
C!() foo2(int* a)
{
auto b = B!()(a);
return b.c;
}
}
void main()
{
scope int* a;
C!() c;
// Error: scope variable `a` assigned to non-scope parameter `a` calling `foo`
c.foo(a);
}
a);
}
```
Comment #1 by timon.gehr — 2023-06-11T18:28:35Z
Do we really want `scope` inference on virtual methods? The code type checks without deprecation if you mark both methods as `final`.
Comment #2 by timon.gehr — 2023-06-11T18:45:41Z
If inferring `return scope` on `a` was not the intention, can you maybe clarify how a fix for this issue would work?
Comment #3 by dkorpel — 2023-06-11T20:28:14Z
(In reply to timon.gehr from comment #1)
> Do we really want `scope` inference on virtual methods?
Good point, I missed that the method is virtual. I think this would be invalid then. (Though of course the enhancement for separate lifetimes for separate aggregate fields still stands)
Comment #4 by robert.schadek — 2024-12-13T19:29:39Z