digitalmars.D.learn - scope variable values assigned to non-scope this.placeholder
- Alexandru Ermicioi (31/31) Aug 06 2018 Hi Dlang community!
- vit (4/9) Aug 06 2018 Parameter values must be `return scope` and this need to be in
Hi Dlang community! I've been playing with dip1000 and scope storage class and stumbled upon a strange error that I can't to understand yet. Here is minimized version of code that generates the error: The link: https://run.dlang.io/is/rg2Odu ------------------------------ import std.stdio; import std.range; import std.algorithm; safe: class C { const int*[] placeholder; this(scope int*[] values) { this.placeholder = values; } } void main() { auto array = iota(0, 20).map!((int i) => new int(i)).array; auto c = new C(array); writeln(c.placeholder.map!(p => *p)); } ------------------------------ I'm not sure what I'm doing wrong, but from what I understand it should check 'this' lifetime to lifetime of scoped 'values' and error only in case when passed value has shorter lifetime than the container itself. I'll be thankful if someone could explain what is wrong with this example. Regards, Alexandru.
Aug 06 2018
On Monday, 6 August 2018 at 20:29:29 UTC, Alexandru Ermicioi wrote:Hi Dlang community! I've been playing with dip1000 and scope storage class and stumbled upon a strange error that I can't to understand yet. Here is minimized version of code that generates the error: [...]Parameter values must be `return scope` and this need to be in compiler: https://issues.dlang.org/show_bug.cgi?id=19097
Aug 06 2018