Thread overview
[Issue 15859] opApply resolution on attributes
Apr 02, 2016
Kenji Hara
Oct 08, 2018
Bolpat
April 01, 2016
https://issues.dlang.org/show_bug.cgi?id=15859

qs.il.paperinik@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|Windows                     |All
           Severity|enhancement                 |minor

--
April 02, 2016
https://issues.dlang.org/show_bug.cgi?id=15859

--- Comment #1 from qs.il.paperinik@gmail.com ---
(In reply to qs.il.paperinik from comment #0)
> struct X
> {
>     int opApply(int delegate(string) dg)
>     {
>         return dg("impure");
>     }
> 
>     int opApply(int delegate(string) pure dg) pure
>     {
>         return dg("pure");
>     }
> }
> 
> void main()
> {
>     X x;
>     string result;
>
>     [ ... ]
>
>     /+ (1)
>     foreach (string s; x)
>     {
>         result = s;
>     }
>     writeln(result); // x.opApply matches more than one declaration
>     +/
>     /+ (2)
>     foreach (string s; x)
>     {
>         result = s;
>         write("");
>     }
>     writeln(result); // x.opApply matches more than one declaration
>     +/
> }

For (1) this is true to some extent. The constructed delegate is pure, but can
be matched to the non-pure version of opApply.
For (2) the compiler rejects valid because the delegate is impure and can only
match the impure opApply.

--
April 02, 2016
https://issues.dlang.org/show_bug.cgi?id=15859

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid
           Hardware|x86_64                      |All
           Severity|minor                       |normal

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/5621

--
October 08, 2018
https://issues.dlang.org/show_bug.cgi?id=15859

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Bolpat <qs.il.paperinik@gmail.com> ---


*** This issue has been marked as a duplicate of issue 15624 ***

--