www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4889] New: Declarator in "if" statement allows name shadowing

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

           Summary: Declarator in "if" statement allows name shadowing
           Product: D
           Version: D2
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tomash.brechko gmail.com



13:24:55 PDT ---
The following compiles without error with dmd 2.049:

void
main()
{
  int i = 1;
  if (int i = 2)
    {
      assert(i == 2);
    }
  assert(i == 1);
}

It seems prohibiting such shadowing would be in line with block shadowing
rules.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4889


Stewart Gordon <smjg iname.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
                 CC|                            |smjg iname.com
         OS/Version|Linux                       |All



I'm not sure if the classification of this as enhancement is correct.  The
mention of the restriction is under ScopeStatement

"Even though a new scope is introduced, local symbol declarations cannot shadow
(hide) other local symbol declarations in the same function."

but was the intent of this statement that it would apply just as well to a
variable declared in an if statement?  After all, it seems to me that reality
its scope is that of the ScopeStatement, even though it isn't lexically within
it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4889


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com
            Version|D2                          |D1
           Severity|enhancement                 |normal



Errors in D2 (2.053) but still allowed in D1 (1.068)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 15 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4889


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|spec                        |
                 CC|                            |bugzilla digitalmars.com



23:28:02 PST ---
D1 only bug, not a spec issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 23 2012