[Issue 21209] scope attribute inference with does not work well with foreach
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jun 1 12:50:59 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21209
Dennis <dkorpel at live.nl> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dkorpel at live.nl
Hardware|x86_64 |All
OS|Linux |All
--- Comment #3 from Dennis <dkorpel at live.nl> ---
Worth noting that scope inference also fails on foreach loops of 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
--
More information about the Digitalmars-d-bugs
mailing list