Thread overview
[Issue 17814] bad output of "static foreach" with -vcg-ast
Sep 07, 2017
ZombineDev
Sep 07, 2017
timon.gehr@gmx.ch
Sep 07, 2017
Rainer Schuetze
Sep 07, 2017
timon.gehr@gmx.ch
September 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

ZombineDev <petar.p.kirov@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |petar.p.kirov@gmail.com

--
September 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

uplink.coder@googlemail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |uplink.coder@googlemail.com

--- Comment #1 from uplink.coder@googlemail.com ---
Ah yes. -vcg-ast has not been updated for static foreach I think.
.....
It seems like it has been already though ....
Maybe the created AST-Nodes are non-persistent .... which would make static
foreach quite volatile after all

--
September 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timon.gehr@gmx.ch

--- Comment #2 from timon.gehr@gmx.ch ---
Dumping the AST of:

static if(true){
    enum a = 1;
}

with "dmd -c -vcg-ast test.d" yields:

import object;
static if (true)
{
    enum int a = 1;
}


Therefore, shouldn't the expected output be:

static foreach(enum i; 0..3)
{
    mixin("int a" ~ i.stringof ~ " = 1;");
}

?

--
September 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

--- Comment #3 from Rainer Schuetze <r.sagitario@gmx.de> ---
If it correctly represents the original code, it should be ok, too.

I expected the dump to have expanded all compile time transformations and lowerings, but obviously it does not. I just tried -vcg-ast on:

mixin("int a" ~ 1.stringof ~ " = 1;");

and it yields

import object;
mixin("int a1" ~ " = 1;");

so it's at some random intermediate step.

--
September 07, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

--- Comment #4 from timon.gehr@gmx.ch ---
https://github.com/dlang/dmd/pull/7126

--
September 16, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

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

https://github.com/dlang/dmd/commit/4317772a132873b9b0cf527312fe8b35e8b11265 fix Issue 17814 - bad output of "static foreach" with -vcg-ast

https://github.com/dlang/dmd/commit/591c7bbfae7fa0781222dcb15a91a40214fc2976 Merge pull request #7126 from tgehr/fix17814

fix Issue 17814 - bad output of "static foreach" with -vcg-ast

--
October 01, 2017
https://issues.dlang.org/show_bug.cgi?id=17814

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

https://github.com/dlang/dmd/commit/4317772a132873b9b0cf527312fe8b35e8b11265 fix Issue 17814 - bad output of "static foreach" with -vcg-ast

https://github.com/dlang/dmd/commit/591c7bbfae7fa0781222dcb15a91a40214fc2976 Merge pull request #7126 from tgehr/fix17814

--