Thread overview
[Issue 19829] __traits(isSame) returns true for some non-local delegate lambdas even when they are different
Apr 26, 2019
ag0aep6g
Apr 26, 2019
Basile-z
Apr 26, 2019
Simen Kjaeraas
Apr 26, 2019
Dlang Bot
May 30, 2019
Dlang Bot
Mar 21, 2020
Basile-z
April 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19829

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |ag0aep6g@gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
Two observations:

1) This prints "true" even though the two lambdas are clearly not the same:

    pragma(msg, __traits(isSame, i => x[i], a => a));

This is a bug in itself.

2) In the original code, when I move `arr` to global scope, then all writelns correctly print "Different".

This suggests that, in the context of `test` and __traits(isSame, ...), map1 might be considered to not have access to arr.

--
April 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19829

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
looks like a 2.079.z regression : https://run.dlang.io/is/LCV9pX

--
April 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19829

--- Comment #3 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
Not really - lambda comparison was implemented in 2.079. Before that any comparison of lambdas with isSame would return false.

Anyways, the core issue is `x` doesn't impact the serialization of lambdas, while it should render the lambda incomparable. Fixed here: https://github.com/dlang/dmd/pull/9710

--
April 26, 2019
https://issues.dlang.org/show_bug.cgi?id=19829

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Biotronic created dlang/dmd pull request #9710 "Fix issue 19829 - __traits(isSame) returns true for some non-local de…" fixing this issue:

- Fix issue 19829 - __traits(isSame) returns true for some non-local delegate lambdas even when they are different

https://github.com/dlang/dmd/pull/9710

--
May 30, 2019
https://issues.dlang.org/show_bug.cgi?id=19829

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #9710 "Fix issue 19829 - __traits(isSame) returns true for some non-local de…" was merged into master:

- c4782963597ce3e719a10d218a7933b69d2dafac by Biotronic:
  Fix issue 19829 - __traits(isSame) returns true for some non-local delegate
lambdas even when they are different

https://github.com/dlang/dmd/pull/9710

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=19829

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--