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 #1 by thomas-dloop — 2006-04-02T07:00:28Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-04-02: > 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 > } > } > } Added to DStress as http://dstress.kuehne.cn/run/n/nested_class_04_A.d http://dstress.kuehne.cn/run/n/nested_class_04_B.d http://dstress.kuehne.cn/run/n/nested_class_04_C.d http://dstress.kuehne.cn/run/n/nested_class_04_D.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEL8Fe3w+/yD4P9tIRAvMiAJ4xocBUc7QrAdz9xYo/gEc5JGTp3QCgiHDC HM8yrnMDytQ10J3ubJZWjcA= =LreD -----END PGP SIGNATURE-----
Comment #2 by bugzilla — 2006-06-18T02:20:55Z
Works in 0.160.
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; }