← Back to index
|
Original Bugzilla link
Bug 24500 – [REG2.101] Incorrect escape error on scope lazy T...
Status
NEW
Severity
critical
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-04-13T19:29:52Z
Last change time
2024-12-13T19:34:41Z
Keywords
industry, rejects-valid
Assigned to
No Owner
Creator
johanengelen
Moved to GitHub: dmd#20440 →
Comments
Comment #0
by johanengelen — 2024-04-13T19:29:52Z
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
Comment #1
by johanengelen — 2024-04-13T19:32:15Z
Workaround: ``` this(const ref FixedArray!(int, 10) _errStr) { auto a = _errStr.slice; A(a); } ```
Comment #2
by robert.schadek — 2024-12-13T19:34:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB
https://github.com/dlang/dmd/issues/20440
DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB