digitalmars.D.bugs - Nested types can't be forward referenced
- Stewart Gordon <smjg_1998 yahoo.com> May 31 2005
- Lars Ivar Igesund <larsivar igesund.net> May 31 2005
- Stewart Gordon <smjg_1998 yahoo.com> May 31 2005
- Lars Ivar Igesund <larsivar igesund.net> May 31 2005
- Hasan Aljudy <hasan.aljudy gmail.com> May 31 2005
- Stewart Gordon <smjg_1998 yahoo.com> Jun 01 2005
- Hasan Aljudy <hasan.aljudy gmail.com> Jun 01 2005
- Stewart Gordon <smjg_1998 yahoo.com> Jun 01 2005
- Hasan Aljudy <hasan.aljudy gmail.com> Jun 01 2005
- Stewart Gordon <smjg_1998 yahoo.com> Jun 02 2005
- Thomas Kuehne <thomas-dloop kuehne.this-is.spam.cn> Jun 01 2005
Using DMD 0.125, Windows 98SE.
----------
struct Qwert {
Yuiop.Asdfg hjkl;
}
struct Yuiop {
struct Asdfg {
int zxcvb;
}
}
----------
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no
property 'Asdfg' for type 'Yuiop'
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2):
Yuiop.Asdfg is used as a type
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable
nesttype_forward.Qwert.hjkl voids have no value
----------
OTOH if Yuiop is instead a class, then the error is
----------
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class
nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg'
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class
nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg'
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no
property 'Asdfg' for type 'nesttype_forward.Yuiop'
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2):
Yuiop.Asdfg is used as a type
D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable
nesttype_forward.Qwert.hjkl voids have no value
----------
Stewart.
--
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
May 31 2005
Stewart Gordon wrote:Using DMD 0.125, Windows 98SE. ---------- struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } } ---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- OTOH if Yuiop is instead a class, then the error is ---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'nesttype_forward.Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- Stewart.
From the Nested functions documentation: "Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other:" So I suppose that this isn't really a bug, but more like a very bad error message. The docs also say that the restriction might be removed in the future. Lars Ivar Igesund
May 31 2005
Lars Ivar Igesund wrote: <snip>From the Nested functions documentation: "Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other:"
Non sequitur. That's nested _functions_. This is nested _types_. Moreover, they're somewhat different concepts. Functions define a sequence of actions. Types don't. Moreover, aren't nested functions only accessible from the scope in which they're defined? Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
May 31 2005
Stewart Gordon wrote:Lars Ivar Igesund wrote: <snip>From the Nested functions documentation: "Unlike module level declarations, declarations within function scope are processed in order. This means that two nested functions cannot mutually call each other:"
Non sequitur. That's nested _functions_. This is nested _types_. Moreover, they're somewhat different concepts. Functions define a sequence of actions. Types don't. Moreover, aren't nested functions only accessible from the scope in which they're defined? Stewart.
Probably a good point. Woke up to early this morning... Lars Ivar Igesund
May 31 2005
Stewart Gordon wrote:Using DMD 0.125, Windows 98SE. ---------- struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } }
To my humble understanding, nested types only exist inside their "outer" type. Asdfg only exists inside the scope of Yuiop.---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- OTOH if Yuiop is instead a class, then the error is ---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'nesttype_forward.Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- Stewart.
May 31 2005
Hasan Aljudy wrote:Stewart Gordon wrote:Using DMD 0.125, Windows 98SE. ---------- struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } }
To my humble understanding, nested types only exist inside their "outer" type.
To your humble understanding indeed. Just try moving Qwert to below Yuiop. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jun 01 2005
Stewart Gordon wrote:Hasan Aljudy wrote:Stewart Gordon wrote:Using DMD 0.125, Windows 98SE. ---------- struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } }
To my humble understanding, nested types only exist inside their "outer" type.
<snip> To your humble understanding indeed. Just try moving Qwert to below Yuiop. Stewart.
If you imply that Yuiop.Asdfg becomes known to everything that comes /after/ it, then maybe /that/ is the bug.
Jun 01 2005
Hasan Aljudy wrote: <snip>If you imply that Yuiop.Asdfg becomes known to everything that comes /after/ it, then maybe /that/ is the bug.
That's basically what I said. I.e. the order of declarations at module or class/struct/union level is supposed not to matter. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jun 01 2005
Stewart Gordon wrote:Hasan Aljudy wrote: <snip>If you imply that Yuiop.Asdfg becomes known to everything that comes /after/ it, then maybe /that/ is the bug.
That's basically what I said. I.e. the order of declarations at module or class/struct/union level is supposed not to matter. Stewart.
I meant to say that maybe the bug is actually in Yuiop.Asdfg being /known/ outside Yuiop when they come after it; it shouldn't be known there. so the bug is not in being unknown to things above it, it's in being known to things below it.
Jun 01 2005
Hasan Aljudy wrote: <snip>I meant to say that maybe the bug is actually in Yuiop.Asdfg being /known/ outside Yuiop when they come after it; it shouldn't be known there. so the bug is not in being unknown to things above it, it's in being known to things below it.
Wrong. Members of a class/struct/union have to be known to things outside it. Otherwise how would you use the class/struct/union? And unless you can find a nook or cranny of the spec that states otherwise, then nested types aren't an exception. Stewart. -- My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Jun 02 2005
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Stewart Gordon schrieb am Tue, 31 May 2005 11:47:08 +0100:Using DMD 0.125, Windows 98SE. ---------- struct Qwert { Yuiop.Asdfg hjkl; } struct Yuiop { struct Asdfg { int zxcvb; } } ---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- OTOH if Yuiop is instead a class, then the error is ---------- D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(5): class nesttype_forward.Yuiop is forward referenced when looking for 'Asdfg' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): no property 'Asdfg' for type 'nesttype_forward.Yuiop' D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): Yuiop.Asdfg is used as a type D:\My Documents\Programming\D\Tests\bugs\nesttype_forward.d(2): variable nesttype_forward.Qwert.hjkl voids have no value ---------- Stewart.
Added to DStress as http://dstress.kuehne.cn/run/f/forward_reference_12_A.d http://dstress.kuehne.cn/run/f/forward_reference_12_B.d http://dstress.kuehne.cn/run/f/forward_reference_12_C.d http://dstress.kuehne.cn/run/f/forward_reference_12_D.d http://dstress.kuehne.cn/run/f/forward_reference_12_E.d http://dstress.kuehne.cn/run/f/forward_reference_12_F.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFCni+23w+/yD4P9tIRAo9TAKC4+n0Mt4RfxBXfij1hMxTUoARq5QCfdQbI p320uR1KntTb5FnqF47ktT0= =TmEh -----END PGP SIGNATURE-----
Jun 01 2005









Lars Ivar Igesund <larsivar igesund.net> 