Bug 19213 – goto skips declaration of variable in std.algorithm.iteration.joiner
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-09-03T10:09:14Z
Last change time
2019-01-02T04:56:52Z
Assigned to
Eduard Staniloiu
Creator
arne.ludwig
Comments
Comment #0 by arne.ludwig — 2018-09-03T10:09:14Z
The upgrade of libphobos 2.081.2-1 -> 2.082.0-1 on Arch Linux introduced this error. I do not have the time to investigate the error in detail but wanted to report it anyway. Here is the full error message:
/usr/include/dlang/dmd/std/algorithm/iteration.d-mixin-2675(2677,31): Error: goto skips declaration of variable std.algorithm.iteration.joiner!(FilterResult!(isAmgiguouslyAlignedRead, ChunkByImpl!(haveEqualIds, FilterResult!(unaryFun, AlignmentChain[])))).joiner.Result.this.__tmpfordtor3418 at /usr/include/dlang/dmd/std/algorithm/iteration.d-mixin-2675(2687,28)
Comment #1 by issues.dlang — 2018-11-04T22:07:23Z
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.
Comment #2 by issues.dlang — 2018-11-04T22:09:53Z
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
Comment #3 by mrjnewt — 2018-11-05T22:17:59Z
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.
Comment #4 by arne.ludwig — 2018-12-17T17:06:25Z
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;
}
Comment #5 by kinke — 2018-12-17T20:38:54Z
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.
Comment #6 by edi33416 — 2018-12-19T16:36:33Z
(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
Comment #7 by github-bugzilla — 2019-01-02T04:56:51Z