[Issue 24500] New: [REG2.101] Incorrect escape error on scope lazy T...
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Apr 13 19:29:52 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24500
Issue ID: 24500
Summary: [REG2.101] Incorrect escape error on scope lazy T...
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: critical
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: johanengelen at weka.io
Testcase:
```
struct FixedArray(T, size_t capacity) {
size_t _length;
T[capacity] _elems;
inout(T)[] slice() inout {
return _elems[0 .. _length];
}
}
struct A
{
static void opCall(T...)(scope lazy T args); // Adding `lazy` creates the
error.
}
struct B {
void foo(const ref FixedArray!(int, 10) _errStr) {
A(_errStr.slice); // Works.
}
this(const ref FixedArray!(int, 10) _errStr) {
A(_errStr.slice); // In constructor it does not work.
}
}
```
Errors with `dmd -c testcase.d`:
testcase.d(21): Error: escaping reference to outer local variable `_errStr`
Deprecation appeared in dmd 2.101, became an error in 2.103.
Closely related bug: https://issues.dlang.org/show_bug.cgi?id=23667
--
More information about the Digitalmars-d-bugs
mailing list