July 19, 2017
https://issues.dlang.org/show_bug.cgi?id=4733

--- Comment #37 from github-bugzilla@puremagic.com ---
Commits pushed to dmd-cxx at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/727233c9c5c1d81d13527f74b0a640f546f28a6c Fix Issue 4733 - Possible bugs caused by dynamic arrays in boolean evaluation context

https://github.com/dlang/dmd/commit/b9177ab9322f8fac7f20f279a5517eda26734ef9 Merge pull request #2885 from yebblies/issue4733

https://github.com/dlang/dmd/commit/72e8bfd2ac371d9a2acc34d7313882a5c4547ce0 Revert "Fix Issue 4733 - Possible bugs caused by dynamic arrays in boolean evaluation context"

https://github.com/dlang/dmd/commit/ef0bb27a609ffa9102a7bac713e4f418f16e92c1 Merge pull request #4623 from andralex/fix-array-to-bool-warning

--
November 20
https://issues.dlang.org/show_bug.cgi?id=4733

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #38 from Nick Treleaven <nick@geany.org> ---
For the record, this post described why the revert happened: https://forum.dlang.org/post/mr540j$1533$1@digitalmars.com

"The main reason why it caused issues is this nice idiom:

if(auto arr = someFunction())
{
   // use arr
}

This would HAVE to be split out to two statements, and the arr variable would be scoped outside of the if statement."

I attempted to make it obsolete: https://github.com/dlang/dmd/pull/15413

But that was rejected. I still think it would be good to do for editions. If that is still a no-go then it seems we need something like:

if ((auto arr = expr).ptr)

However, would `arr` then be declared in the `else` branch? If so that is still not a replacement for the feature.

Another option would be to allow `if (auto arr = expr)` but allow no other uses of an array as a boolean.

--
November 22
https://issues.dlang.org/show_bug.cgi?id=4733

--- Comment #39 from anonymous4 <dfj1esp02@sneakemail.com> ---
AIU some believe it's a feature, not a bug? Then it becomes a style rule. Editions are only supposed for consensus.

--
November 22
https://issues.dlang.org/show_bug.cgi?id=4733

--- Comment #40 from Nick Treleaven <nick@geany.org> ---
Isn't there a consensus that the feature is bug prone (at the very least for
new users)?

--
November 22
https://issues.dlang.org/show_bug.cgi?id=4733

--- Comment #41 from Steven Schveighoffer <schveiguy@gmail.com> ---
I would vote for `if(arr)` to be true only if length > 0, instead of making it
illegal.

But some people do distinguish between null arrays and empty arrays, and this would be a breaking change for that code.

> I still think it would be good to do for editions.

Yes, please! If editions ever becomes a thing, this should be considered.

--
November 26
https://issues.dlang.org/show_bug.cgi?id=4733

Paul Backus <snarwin+bugzilla@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |snarwin+bugzilla@gmail.com

--- Comment #42 from Paul Backus <snarwin+bugzilla@gmail.com> ---
> If that is still a no-go then it seems we need something like:
>
> if ((auto arr = expr).ptr)

In C++17, you can write it like this:

    if (auto arr = expr; arr.ptr)

--
1 2
Next ›   Last »