Jump to page: 1 24  
Page
Thread overview
[Issue 199] New: Label causes scope to collapse into parent
Jun 16, 2006
d-bugmail
Jun 20, 2006
d-bugmail
Jun 29, 2006
d-bugmail
Jan 23, 2007
d-bugmail
Jan 23, 2007
d-bugmail
Apr 05, 2007
d-bugmail
Jun 23, 2008
d-bugmail
Jun 23, 2008
d-bugmail
May 29, 2013
Nick Treleaven
May 29, 2013
Stewart Gordon
May 29, 2013
Stewart Gordon
May 29, 2013
Stewart Gordon
May 29, 2013
Stewart Gordon
May 29, 2013
Ali Cehreli
May 29, 2013
Stewart Gordon
May 29, 2013
Ali Cehreli
May 30, 2013
Nick Treleaven
May 30, 2013
Nick Treleaven
May 30, 2013
Stewart Gordon
Jun 06, 2013
Nick Treleaven
June 16, 2006
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.


-- 

June 20, 2006
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.


-- 

June 29, 2006
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


-- 

January 23, 2007
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


-- 

January 23, 2007
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


-- 

April 05, 2007
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.


-- 

June 23, 2008
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.


-- 

June 23, 2008
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


-- 

May 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=199


monarchdodra@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |monarchdodra@gmail.com
         Resolution|WONTFIX                     |


--- Comment #10 from monarchdodra@gmail.com 2013-05-29 03:00:58 PDT ---
According to this talk: http://forum.dlang.org/thread/ohctkdnupmbprglobwtc@forum.dlang.org#post-axonofactkyzpagilcbm:40forum.dlang.org

The spec does NOT state it should work that way.

Even if it did:
- Doing it this way buys nothing, as you get the same result simply by... not
typing the block
- Is bug prone (accidental labeling)
- Potentially creates different behavior from C code.

NB: The original example is wrong because of shadowing. But this one is more viable.

//----
void main()
{
    {
        uint foo;
    } end_first_block:

    {
        uint foo;
    } end_second_block:

    {
        uint foo; //main.d(12): Error: declaration main.main.foo is already
defined
    } end_third_block:

    return;
}
//----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=199


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #11 from bearophile_hugs@eml.cc 2013-05-29 03:10:51 PDT ---
(In reply to comment #10)

> - Potentially creates different behavior from C code.

What are the conditions for it to create different behaviour? Maybe you can show two programs, in C and D, that behave differently.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2 3 4