Bug 21990 – scope inference fails with foreach on AliasSeq

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-06-03T08:00:33Z
Last change time
2024-12-13T19:16:47Z
Assigned to
No Owner
Creator
Dennis
See also
https://issues.dlang.org/show_bug.cgi?id=21209
Moved to GitHub: dmd#19938 →

Comments

Comment #0 by dkorpel — 2021-06-03T08:00:33Z
Continuation of issue 21209 Scope inference fails on foreach loops of tuples / alias sequences: ``` @safe: void foo(A...)(A args) { static int x; x++; // force impure for issue 20150 foreach(a; args) { // gets lowered to unrolled loop with `string a = _param_0;` } } void main() { scope string x = "hey"; foo(x); } ``` Error: scope variable `x` assigned to non-scope parameter `_param_0` calling foo!string.foo It gets lowered to a special 'unrolled' loop which puts the loop variable in a temporary (`string a = _param_0;`), which makes _param_0 non-scope.
Comment #1 by robert.schadek — 2024-12-13T19:16:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19938 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB