Thread overview
[Issue 19213] goto skips declaration of variable in std.algorithm.iteration.joiner
Nov 04, 2018
Jonathan M Davis
Nov 04, 2018
Jonathan M Davis
Nov 05, 2018
Justin
Dec 14, 2018
Eduard Staniloiu
Dec 17, 2018
kinke@gmx.net
Dec 19, 2018
Eduard Staniloiu
November 04, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

Jonathan M Davis <issues.dlang@jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang@jmdavisProg.co
                   |                            |m

--- Comment #1 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
So, you have a piece of code that compiled with 2.081.2 that now fails with 2.082.0, and this is the error message? We need a code example that reproduces the problem, or we can't really do anything.

--
November 04, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

--- Comment #2 from Jonathan M Davis <issues.dlang@jmdavisProg.com> ---
If you can't easily provide a simplified example, when you have time, you can use dustmite to try to reduce your code to provide one: https://github.com/CyberShadow/DustMite/wiki

--
November 05, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

Justin <mrjnewt@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrjnewt@gmail.com
           Severity|normal                      |regression

--- Comment #3 from Justin <mrjnewt@gmail.com> ---
I ran into this myself when attempting compile a service that we've had in production for more than a year after updating to DMD 2.083.0.  I was able to create a small artificial repro case, runnable here: https://run.dlang.io/is/ssx7CP


import std.algorithm;
import std.range;
void main()
{
    static struct Rec
    {
        int foo;
    }
    auto results = [[1,2], [3,4]]
                       .map!(q => q.map!Rec.chunkBy!"a.foo")
                       .joiner;
}

This is definitely a regression as this code builds with DMD 2.080.1 and prior.

--
December 14, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

Eduard Staniloiu <edi33416@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edi33416@gmail.com
           Assignee|nobody@puremagic.com        |edi33416@gmail.com

--
December 17, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

--- Comment #4 from arne.ludwig@posteo.de ---
I reduced the example a bit more. The struct is not involved in the error.


import std.algorithm;
import std.range;
void main()
{
    auto results = [[1,2], [3,4]]
                       .map!(q => q.chunkBy!"a")
                       .joiner;
}

--
December 17, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

kinke@gmx.net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #5 from kinke@gmx.net ---
While I'm not convinced the `goto`s in the `pop{Front,Back}EmptyElements` mixins in Phobos are the most elegant way of expressing the logic, the issue is that the frontend warns about a skipped *temporary* variable declaration, whose lifetime doesn't extend to the goto target.

It may be enough to exclude `STC.temp` vars from the error, just like for
`STC.exptemp` in
https://github.com/dlang/dmd/blob/06d579823bddf8cae735408f6cc81d4789ace520/src/dmd/statement.d#L2270.
I think the temporaries are bound to their statement (which cannot cross the
goto label) but I'm not 100% sure that's always the case.

--
December 19, 2018
https://issues.dlang.org/show_bug.cgi?id=19213

--- Comment #6 from Eduard Staniloiu <edi33416@gmail.com> ---
(In reply to kinke from comment #5)
> While I'm not convinced the `goto`s in the `pop{Front,Back}EmptyElements` mixins in Phobos are the most elegant way of expressing the logic, the issue is that the frontend warns about a skipped *temporary* variable declaration, whose lifetime doesn't extend to the goto target.
> 

This is true: the issue spawns from the frontend.

Until this get's fixed, I have a PR to fix this https://github.com/dlang/phobos/pull/6803

--
January 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19213

--- Comment #7 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/6572e4abb338127e2fd12cd562133e8f71a35311 Fix Issue 19213 - goto skips declaration of variable in std.algorithm.iteration.joiner

https://github.com/dlang/phobos/commit/07ea0e020113320f01a2028d40e5d494934dc9b0 Merge pull request #6803 from edi33416/issue_19213

Fix Issue 19213 - goto skips declaration of variable in std.algorithm…

--
January 02, 2019
https://issues.dlang.org/show_bug.cgi?id=19213

github-bugzilla@puremagic.com changed:

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

--