Thread overview
[Issue 8444] New: Cannot use dot to disambiguate between local method and class declaration
Jul 26, 2012
Andrej Mitrovic
Jul 26, 2012
Jonathan M Davis
Jul 26, 2012
Andrej Mitrovic
Oct 04, 2012
Andrej Mitrovic
Oct 04, 2012
Andrej Mitrovic
July 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8444

           Summary: Cannot use dot to disambiguate between local method
                    and class declaration
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-07-25 17:13:47 PDT ---
module test;
class Foo
{
    void foo(.test.Foo) { }  // should work
    void test() { }
}

void main() { }

test.d(5): Error: identifier 'test' of '.test.Foo' is not defined
test.d(5): Error: .test.Foo is used as a type

Not that it does work if "test" is an *imported* module, e.g.:

module mymod;
import test;

class Bar
{
    void foo(.test.Foo) { }
    void test() { }
}

void main() { }

This compiles.

I'd really like the first case to work because it makes code generation easier to do (so I'm not talking about handwritten code here). But it's low priority for me, I can implement workarounds.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8444


Jonathan M Davis <jmdavisProg@gmx.com> changed:

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


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-07-25 17:23:49 PDT ---
Did it work in 2.059? Or is that what you're using? Even if it's minor, if it worked in 2.059 and doesn't work in 2.0560, it needs to be marked as a regression.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
July 26, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8444



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-07-25 17:35:20 PDT ---
(In reply to comment #1)
> Did it work in 2.059? Or is that what you're using? Even if it's minor, if it worked in 2.059 and doesn't work in 2.0560, it needs to be marked as a regression.

2.050 is the earliest I've tested but I don't think it ever worked. It's not odd it wasn't found since using 'Foo' would work. This just seems like an edge-case.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8444


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

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


--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-03 20:17:10 PDT ---
Looking at the DMD code I think my bug report is invalid. Dot looks up in the module scope, but there's no 'test' in the test module scope (unless it's an import of another module named 'test').

The OP code needs to use ".Foo" instead.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 04, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8444



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-03 20:19:20 PDT ---
(In reply to comment #3)
> Looking at the DMD code I think my bug report is invalid. Dot looks up in the module scope, but there's no 'test' in the test module scope (unless it's an import of another module named 'test').
> 
> The OP code needs to use ".Foo" instead.

Also if clashes are of concern, the user can use an alias:

alias test ThisModule;

class Foo
{
    void foo(.ThisModule.Foo) { }
}

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