April 13 [Issue 24500] New: [REG2.101] Incorrect escape error on scope lazy T... | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: johanengelen@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 -- |
Copyright © 1999-2021 by the D Language Foundation