www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 199] New: Label causes scope to collapse into parent

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199

           Summary: Label causes scope to collapse into parent
           Product: D
           Version: 0.160
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: ericanderton yahoo.com


When using a label directly before an anonymous scope (set of curly brackets),
it causes the anonymous scope to behave as though its contents are declared in
the parent scope directly.  This causes variable names to collide should they
share the same name between child and parent:

void main(){
        uint foo;
        x:              
        {
                uint foo;
        }
}

test.d(5): declaration test.main.foo is already defined

Adding '{}' immediately after the label seems to be a viable workaround.


-- 
Jun 16 2006
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


ericanderton yahoo.com changed:

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




------- Comment #1 from ericanderton yahoo.com  2006-06-20 15:01 -------
DMD 0.161 disallows shadowing of local vars.  So this is now a non-issue.


-- 
Jun 20 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |




------- Comment #2 from thomas-dloop kuehne.cn  2006-06-29 08:42 -------
The scope is still being collapsed.

Added to DStress as
http://dstress.kuehne.cn/run/s/scope_13_A.d
http://dstress.kuehne.cn/run/s/scope_13_B.d


-- 
Jun 29 2006
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |WORKSFORME




------- Comment #3 from davidl 126.com  2007-01-22 23:52 -------
yeah, 1.0 doesn't allow shadowing of local var. it's not an issue anymore. and
don't expect walter would fix the old revision


-- 
Jan 22 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


braddr puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |




------- Comment #4 from braddr puremagic.com  2007-01-23 00:30 -------
David, I appreciate your trying to help, but this bug is NOT fixed.  The
scope_13_A test case that Thomas added is still failing.  You can see that
either by trying it yourself (which I just did), or looking at the test results
here:

    http://dstress.kuehne.cn/www/dmd-1.00.html


-- 
Jan 22 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com




------- Comment #5 from smjg iname.com  2007-04-05 07:22 -------
On the basis of what you say, the compiler is behaving according to the spec,
which states

http://www.digitalmars.com/d/statement.html#LabeledStatement
LabelledStatement:
    Identifier ':' NoScopeStatement

I'd noticed it before.  But since this bit of the spec is presumably not what
was intended, I'm leaving this issue open.  If there's any temptation to hit
the INVALID button, it should be changed to an enhancement request instead.


-- 
Apr 05 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |WONTFIX




------- Comment #6 from bugzilla digitalmars.com  2008-06-23 17:00 -------
Since the compiler is behaving according to spec, I don't want to change this
because it could break existing code, and there doesn't seem to be a compelling
reason to do so.


-- 
Jun 23 2008
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=199


shro8822 vandals.uidaho.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WONTFIX                     |




------- Comment #7 from shro8822 vandals.uidaho.edu  2008-06-23 17:09 -------
this still fail:

http://dstress.kuehne.cn/run/s/scope_13_A.d


-- 
Jun 23 2008