www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8287] New: When a class with the same name as a module exists within that module and has static members, you're required to do modulename.classname.member() in order to access said members

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

           Summary: When a class with the same name as a module exists
                    within that module and has static members, you're
                    required to do modulename.classname.member() in order
                    to access said members
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tbrisbane hotmail.com



PDT ---
Pretty much exactly what the summary says. Here is an example:

File 1:
module objectA;

class objectA {
  public static void doSomething() {
    ...
  }
}

File 2:
module main;

import objectA;

int main(string[] args) {
  objectA.doSomething(); // Error: undefined identifier 'doSomething'
  objectA.objectA.doSomething(); // Ok
  return 0;
}

Obviously, the compiler is searching for a function called doSomething in the
module objectA, when it should instead recognize that a class called objectA
has been imported and an attempt is being made to access its static member
doSomething().

Please note that this is my first bug submission, so if it's already known (I
did search before posting this) or has a simple fix, please forgive me. :)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 23 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8287




PDT ---
Created an attachment (id=1117)
objectA module

Contains a class called objectA with a static member doSomething()

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




PDT ---
Created an attachment (id=1118)
main module

Attempts to access the objectA class's doSomething member, showing the issue.

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


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
I believe that that's expected behavior.

Just rename the module so that it's all lowercase and the problem is solved.
It's common practice to always name modules using only lowercase letters
anyway.

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


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bearophile_hugs eml.cc
         Resolution|                            |FIXED



I think D is working as designed here. Class and struct names start with an
upper case, while modules start with a lower case. I suggest to close this bug
report as wontfix.

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




PDT ---

 I believe that that's expected behavior.
 
 Just rename the module so that it's all lowercase and the problem is solved.
 It's common practice to always name modules using only lowercase letters
 anyway.
 I think D is working as designed here. Class and struct names start with an
 upper case, while modules start with a lower case. I suggest to close this bug
 report as wontfix.
Fair enough. :) Thanks for your time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 24 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8287


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID


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