digitalmars.D.learn - Bug or not? Statics inside blocks
- Cecil Ward (15/15) Jul 28 2017 The snippet below failed to compile (I think) in the latest DMD -
- Cecil Ward (3/18) Jul 28 2017 Workaround is just to rename one, assuming that avoids a name
- Jonathan M Davis via Digitalmars-d-learn (14/29) Jul 28 2017 Well, based on the error message, I'd say that the restriction is on
- ag0aep6g (4/15) Jul 28 2017 https://issues.dlang.org/show_bug.cgi?id=11720
The snippet below failed to compile (I think) in the latest DMD -
but I can't see the error message in the web-based editor at
dlang.org. It certainly failed to compile under GDC 5.2.0 when
tried out using d.godbolt.org. (Is there any chance of a later
GDC compiler there?)
Is it my bug, or a compiler bug? (name clash at link-time?):
void main()
{
{
immutable static dstring str1 = "a";
}
{
immutable static dstring str1 = "b";
}
}
Jul 28 2017
On Saturday, 29 July 2017 at 01:54:29 UTC, Cecil Ward wrote:
The snippet below failed to compile (I think) in the latest DMD
- but I can't see the error message in the web-based editor at
dlang.org. It certainly failed to compile under GDC 5.2.0 when
tried out using d.godbolt.org. (Is there any chance of a later
GDC compiler there?)
Is it my bug, or a compiler bug? (name clash at link-time?):
void main()
{
{
immutable static dstring str1 = "a";
}
{
immutable static dstring str1 = "b";
}
}
Workaround is just to rename one, assuming that avoids a name
clash at <xx?phase>-time.
Jul 28 2017
On Saturday, July 29, 2017 1:54:29 AM MDT Cecil Ward via Digitalmars-d-learn
wrote:
The snippet below failed to compile (I think) in the latest DMD -
but I can't see the error message in the web-based editor at
dlang.org. It certainly failed to compile under GDC 5.2.0 when
tried out using d.godbolt.org. (Is there any chance of a later
GDC compiler there?)
Is it my bug, or a compiler bug? (name clash at link-time?):
void main()
{
{
immutable static dstring str1 = "a";
}
{
immutable static dstring str1 = "b";
}
}
Well, based on the error message, I'd say that the restriction is on
purpose:
q.d(7): Error: declaration q.main.str1 is already defined in another scope
in main
The bit about "another scope" just wouldn't make sense if it weren't on
purpose, since there is normally no such restriction. That being said, I
have no idea why such a restriction would be in place. It works perfectly
well if the variables aren't static, so it's something about static that's
causing it. I would argue that it _should_ work, so I think that you should
at least open up an enhancement request, but I have no idea what the
compiler devs would say on the matter.
- Jonathan M Davis
Jul 28 2017
On 07/29/2017 03:54 AM, Cecil Ward wrote:
Is it my bug, or a compiler bug? (name clash at link-time?):
void main()
{
{
immutable static dstring str1 = "a";
}
{
immutable static dstring str1 = "b";
}
}
https://issues.dlang.org/show_bug.cgi?id=11720
Ideally (imo), the code would work. The two variables would need
different mangled names. No idea how hard that would be to implement.
Jul 28 2017









Cecil Ward <d cecilward.com> 