[Issue 21209] scope attribute inference with does not work well with foreach

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Feb 19 07:30:14 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21209

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=20674,
                   |                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=20150

--- Comment #2 from ag0aep6g <ag0aep6g at gmail.com> ---
(In reply to Mathias LANG from comment #1)
> The strangest part is that not calling `bar` from the
> foreach makes the error go away.

That's because `bar` is not `pure`. Without the `bar` call, `foo` becomes
`pure` and you're hitting issue 20150 (DMD wrongly assumes that parameters of
`pure` functions can always be `scope`).

When not relying on issue 20150, inference of `scope` is very limited. See also
issue 20674.

--


More information about the Digitalmars-d-bugs mailing list