Bug 80 – Cannot instantiate nested class in nested function
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-04-01T22:33:00Z
Last change time
2014-02-15T02:08:21Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
jarrett.billingsley
Comments
Comment #0 by jarrett.billingsley — 2006-04-01T22:33:18Z
Interesting!
class A
{
class B
{
}
void fork()
{
B b = new B(); // This is okay
void knife()
{
B b = new B(); // No 'this' for nested class B
}
}
}
Blocked me from doing something rather elegant.
Comment #3 by bruno.do.medeiros+deebugz — 2006-06-18T08:16:52Z
(In reply to comment #2)
> Works in 0.160.
Have you tested the DStress testcases?
The original code by Jarrett now compiles, but I think the bug (or at least some other bug) is still there. You see, the 04_B case fails, which is clearly a bug, and the C and D fail to compile, which I think isn't correct too.
Comment #4 by bruno.do.medeiros+deebugz — 2006-06-19T08:58:14Z
(In reply to comment #3)
> (In reply to comment #2)
> > Works in 0.160.
> Have you tested the DStress testcases?
> The original code by Jarrett now compiles, but I think the bug (or at least
> some other bug) is still there. You see, the 04_B case fails, which is clearly
> a bug, and the C and D fail to compile, which I think isn't correct too.
Also, this might be related (or even be the same) as bug 155:
http://d.puremagic.com/bugzilla/show_bug.cgi?id=155
Note the similarity with testcase nested_class_04_B.d
Comment #5 by davidl — 2007-01-22T21:40:25Z
i think no one would fix .150 and the code works in 1.0
Comment #6 by braddr — 2007-01-22T22:07:05Z
According to the dstress results ( http://dstress.kuehne.cn/www/dmd-1.00.html ), A passes but B, C, and D all fail still. How did you test this:
1) hand built, run, and examined or via dstress?
2) what os?
3) which compiler, dmd or gdc?
Comment #7 by clugdbug — 2009-07-22T02:20:40Z
Cases A and B pass, but C and D are still failing (DMD 2.031 and 1.046).
However, it's pretty clear that cases C and D are invalid. A reduced version of C generates this error:
ancient.d(6): Error: this for i needs to be type Outer not type Inner*
and that is correct. 'Inner' is only _defined_ in 'Outer', it's not a _member_ of 'Outer'. (All kinds of bad things would happen if this worked; you wouldn't be able to transfer an Inner from one Outer to another, for example).
Marking as fixed, since the two valid cases are fixed now.
-----
struct Outer{
int i;
struct Inner{
int fest() { return i; }
}
void test(){
Inner z;
int k = z.fest();
}
}
int main(){
Outer outer;
outer.i = 1;
outer.test();
return 0;
}