Bug 8444 – Cannot use dot to disambiguate between local method and class declaration
Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-25T17:13:00Z
Last change time
2012-10-03T20:19:20Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2012-07-25T17:13:47Z
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.
Comment #1 by issues.dlang — 2012-07-25T17:23:49Z
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.
Comment #2 by andrej.mitrovich — 2012-07-25T17:35:20Z
(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.
Comment #3 by andrej.mitrovich — 2012-10-03T20:17:10Z
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.
Comment #4 by andrej.mitrovich — 2012-10-03T20:19:20Z
(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) { }
}