Thread overview
[Issue 16491] Forward referencing and static/shared static module constructors break initialisation
Sep 13, 2016
Sobirari Muhomori
Sep 13, 2016
Ethan Watson
Nov 18, 2016
Jacob Carlborg
Nov 18, 2016
Ethan Watson
Nov 24, 2016
anonymous4
September 13, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #1 from Sobirari Muhomori <dfj1esp02@sneakemail.com> ---
Can't the name be immutable?

immutable string someOtherClassName = SomeOtherClass.stringof;

--
September 13, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #2 from Ethan Watson <gooberman@gmail.com> ---
It is purely for illustrative/example purposes. The data I'm using cannot be immutable.

--
November 18, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

Jacob Carlborg <doob@me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob@me.com

--- Comment #3 from Jacob Carlborg <doob@me.com> ---
Can you show a more extended example(In reply to Ethan Watson from comment #2)
> It is purely for illustrative/example purposes. The data I'm using cannot be immutable.

Can you show a more extended example because the above example can be solved by directly initializing the variable:

__gshared string someOtherClassName = SomeOtherClass.stringof;

--
November 18, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #4 from Ethan Watson <gooberman@gmail.com> ---
Of course it can be solved by assigning this specific string at compile time. Because you remove the shared static constructor.

Replace the contents of the constructor with a writeln and delete the gshared storage. Done. The point is the static constructor and the invalid cyclic dependency between pointers.

No, seriously. That's two people now to have commented on the most irrelevant part of the bug. The title of this bug explains exactly what's wrong.

--
November 18, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy@yahoo.com
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=16673

--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> ---
The issue is simply that you have a cycle. Forward referencing has nothing to do with it.

Unfortunately, this is functioning as designed. Martin has some ideas to make this possibly work, but those haven't been implemented yet. See https://issues.dlang.org/show_bug.cgi?id=16673

--
November 24, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

uplink.coder@googlemail.com changed:

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

--- Comment #6 from uplink.coder@googlemail.com ---
In this case the cycle is non-harmful.
Since no run-time initialized data is used.

We can and should improve the cycle-check.
Preferably in DMD itself, when possible.
I am having a look.

--
November 24, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #7 from anonymous4 <dfj1esp02@sneakemail.com> ---
If it didn't use runtime data, it could be computed at compile time.

--
November 25, 2016
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #8 from Steven Schveighoffer <schveiguy@yahoo.com> ---
(In reply to uplink.coder from comment #6)
> In this case the cycle is non-harmful.
> Since no run-time initialized data is used.

Yes, that is what issue 16673 is about -- using statically available data should not add a dependency.

--
December 07
https://issues.dlang.org/show_bug.cgi?id=16491

--- Comment #9 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/17335

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--