View mode: basic / threaded / horizontal-split · Log in · Help
November 15, 2004
DMD 0.106 is severely broken
It was drawn to my attention that SDWF refuses to compile under DMD 
0.106.  Though there was one thing genuinely wrong with my code, fixing 
this thing revealed even more things wrong with the compiler.

1. Anonymous structs/unions refuse to work, whether in a class or in 
module scope.

----------
import std.stdio;

struct {
	int qwert;
}

void main() {
	writef(qwert);
}
----------
D:\My Documents\Programming\D\Tests\bugs\broken106_struct.d(8): 
undefined identifier qwert
----------

2. Moreover, if a class has an anonymous struct/union, any attempt to 
initialise any of the members causes trouble:

----------
class Qwert {
	struct {
		int yuiop = 13;
	}
	int asdfg = 42;
}
----------
D:\My Documents\Programming\D\Tests\bugs\broken106_init.d(1): class 
broken106_init.Qwert 2duplicate union initialization for asdfg
D:\My Documents\Programming\D\Tests\bugs\broken106_init.d(1): class 
broken106_init.Qwert 2duplicate union initialization for yuiop
----------

3. Private members of nested classes are not accessible, either from the 
containing class, other classes in the module or other global functions 
in the module.

----------
class Qwert {
	this() {
		Yuiop asdfg = new Yuiop;
		asdfg.hjkl();
		asdfg.zxcvb = 69;
	}

	class Yuiop {
		private {
			this() {}
			void hjkl() {}
			int zxcvb;
		}
	}
}

void main() {
	Qwert.Yuiop asdfg = new Qwert.Yuiop;
	asdfg.hjkl();
	asdfg.zxcvb = 105;
}

class Nm {
	this() {
		Qwert.Yuiop asdfg = new Qwert.Yuiop;
		asdfg.hjkl();
		asdfg.zxcvb = 666;
	}
}
----------
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(3): class 
broken106_private.Qwert.Yuiop member this is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(4): class 
broken106_private.Qwert.Yuiop member hjkl is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(5): class 
broken106_private.Qwert.Yuiop member zxcvb is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(18): class 
broken106_private.Qwert.Yuiop member this is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(19): class 
broken106_private.Qwert.Yuiop member hjkl is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(20): class 
broken106_private.Qwert.Yuiop member zxcvb is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(25): class 
broken106_private.Qwert.Yuiop member this is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(26): class 
broken106_private.Qwert.Yuiop member hjkl is not accessible
D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(27): class 
broken106_private.Qwert.Yuiop member zxcvb is not accessible
----------

I invite you all to post any other bugs that have newly appeared in 
0.106 as followups to this thread, to keep them all together. 
Especially those that (like these) have prevented existing projects from 
compiling or running correctly.

Stewart.
November 15, 2004
Re: DMD 0.106 is severely broken
I've added your tests to DStress.
Thomas

Stewart Gordon schrieb am 2004-11-15:
> It was drawn to my attention that SDWF refuses to compile under DMD 
> 0.106.  Though there was one thing genuinely wrong with my code, fixing 
> this thing revealed even more things wrong with the compiler.
>
> 1. Anonymous structs/unions refuse to work, whether in a class or in 
> module scope.
http://svn.kuehne.cn/dstress/run/struct_17.d
http://svn.kuehne.cn/dstress/run/union_11.d

> 2. Moreover, if a class has an anonymous struct/union, any attempt to 
> initialise any of the members causes trouble:
http://svn.kuehne.cn/dstress/compile/struct_18.d
http://svn.kuehne.cn/dstress/compile/union_10.d

> 3. Private members of nested classes are not accessible, either from the 
> containing class, other classes in the module or other global functions 
> in the module.
http://svn.kuehne.cn/dstress/run/private_02.d
http://svn.kuehne.cn/dstress/run/private_03.d
November 15, 2004
Re: DMD 0.106 is severely broken
Stewart Gordon wrote:
> It was drawn to my attention that SDWF refuses to compile under DMD 
> 0.106.  Though there was one thing genuinely wrong with my code, fixing 
> this thing revealed even more things wrong with the compiler.
> 
> 1. Anonymous structs/unions refuse to work, whether in a class or in 
> module scope.
> 
> 2. Moreover, if a class has an anonymous struct/union, any attempt to 
> initialise any of the members causes trouble:
> 

Forgive my forwardness, but why should they? :)

Anonymous structs don't make a whole lot of sense in either of these 
cases.  The only place I can think where they have any use at all is in 
unions.

 -- andy
November 15, 2004
Re: DMD 0.106 is severely broken
Andy Friesen wrote:
<snip>
> Anonymous structs don't make a whole lot of sense in either of these 
> cases.  The only place I can think where they have any use at all is in 
> unions.

Indeed, in the code snippet I posted it's useless.  But in this 
instance, it should either work or complain about a syntax error, not an 
undefined identifier.

As for how I'm using it, SDWF has several instances of an anonymous 
struct within an anonymous union within a class.

Stewart.
November 15, 2004
Re: DMD 0.106 is severely broken
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
news:cn9vah$1shn$1@digitaldaemon.com...
> It was drawn to my attention that SDWF refuses to compile under DMD
> 0.106.  Though there was one thing genuinely wrong with my code, fixing
> this thing revealed even more things wrong with the compiler.
>
> 1. Anonymous structs/unions refuse to work, whether in a class or in
> module scope.
>
> ----------
> import std.stdio;
>
> struct {
> int qwert;
> }
>
> void main() {
> writef(qwert);
> }
> ----------
> D:\My Documents\Programming\D\Tests\bugs\broken106_struct.d(8):
> undefined identifier qwert
> ----------

Anonymous structs at module scope should be diagnosed as an error.


> 2. Moreover, if a class has an anonymous struct/union, any attempt to
> initialise any of the members causes trouble:
>
> ----------
> class Qwert {
> struct {
> int yuiop = 13;
> }
> int asdfg = 42;
> }
> ----------
> D:\My Documents\Programming\D\Tests\bugs\broken106_init.d(1): class
> broken106_init.Qwert 2duplicate union initialization for asdfg
> D:\My Documents\Programming\D\Tests\bugs\broken106_init.d(1): class
> broken106_init.Qwert 2duplicate union initialization for yuiop
> ----------

This is a bug.

> 3. Private members of nested classes are not accessible, either from the
> containing class, other classes in the module or other global functions
> in the module.
>
> ----------
> class Qwert {
> this() {
> Yuiop asdfg = new Yuiop;
> asdfg.hjkl();
> asdfg.zxcvb = 69;
> }
>
> class Yuiop {
> private {
> this() {}
> void hjkl() {}
> int zxcvb;
> }
> }
> }
>
> void main() {
> Qwert.Yuiop asdfg = new Qwert.Yuiop;
> asdfg.hjkl();
> asdfg.zxcvb = 105;
> }
>
> class Nm {
> this() {
> Qwert.Yuiop asdfg = new Qwert.Yuiop;
> asdfg.hjkl();
> asdfg.zxcvb = 666;
> }
> }
> ----------
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(3): class
> broken106_private.Qwert.Yuiop member this is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(4): class
> broken106_private.Qwert.Yuiop member hjkl is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(5): class
> broken106_private.Qwert.Yuiop member zxcvb is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(18): class
> broken106_private.Qwert.Yuiop member this is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(19): class
> broken106_private.Qwert.Yuiop member hjkl is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(20): class
> broken106_private.Qwert.Yuiop member zxcvb is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(25): class
> broken106_private.Qwert.Yuiop member this is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(26): class
> broken106_private.Qwert.Yuiop member hjkl is not accessible
> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(27): class
> broken106_private.Qwert.Yuiop member zxcvb is not accessible
> ----------

I think they should not be accessible.
November 15, 2004
Re: DMD 0.106 is severely broken
Walter schrieb am Montag, 15. November 2004 19:26:
>> 3. Private members of nested classes are not accessible, either from the
>> containing class, other classes in the module or other global functions
>> in the module.
>>
>> ----------
>> class Qwert {
>> this() {
>> Yuiop asdfg = new Yuiop;
>> asdfg.hjkl();
>> asdfg.zxcvb = 69;
>> }
>>
>> class Yuiop {
>> private {
>> this() {}
>> void hjkl() {}
>> int zxcvb;
>> }
>> }
>> }
>>
>> void main() {
>> Qwert.Yuiop asdfg = new Qwert.Yuiop;
>> asdfg.hjkl();
>> asdfg.zxcvb = 105;
>> }
>>
>> class Nm {
>> this() {
>> Qwert.Yuiop asdfg = new Qwert.Yuiop;
>> asdfg.hjkl();
>> asdfg.zxcvb = 666;
>> }
>> }
>> ----------
>> D:\My Documents\Programming\D\Tests\bugs\broken106_private.d(3): class
>> broken106_private.Qwert.Yuiop member this is not accessible
[snip] 
> I think they should not be accessible.

http://digitalmars.com/d/attribute.html :
# Private means that only members of the enclosing class can access the
# member, or members and functions in the same module as the enclosing
# class.
November 16, 2004
Re: DMD 0.106 is severely broken
Walter wrote:
> "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
> news:cn9vah$1shn$1@digitaldaemon.com...
<snip>
>> D:\My Documents\Programming\D\Tests\bugs\broken106_struct.d(8):
>> undefined identifier qwert
>> ----------
> 
> Anonymous structs at module scope should be diagnosed as an error.
<snip>

I guess you're right.  So the bug here is that it defers choking until 
you try to use it?

I gave this as a minimal testcase.  But I'm doing it in class scope, 
where the error is the same.  OK, so maybe anonymous structs at class 
scope aren't particularly useful either, but anonymous unions at class 
scope certainly are.

Stewart.
November 16, 2004
Re: DMD 0.106 is severely broken
"Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
news:cnclos$2nhe$1@digitaldaemon.com...
> Walter wrote:
> > "Stewart Gordon" <smjg_1998@yahoo.com> wrote in message
> > news:cn9vah$1shn$1@digitaldaemon.com...
> <snip>
> >> D:\My Documents\Programming\D\Tests\bugs\broken106_struct.d(8):
> >> undefined identifier qwert
> >> ----------
> >
> > Anonymous structs at module scope should be diagnosed as an error.
> <snip>
>
> I guess you're right.  So the bug here is that it defers choking until
> you try to use it?

Yes.

> I gave this as a minimal testcase.  But I'm doing it in class scope,
> where the error is the same.  OK, so maybe anonymous structs at class
> scope aren't particularly useful either, but anonymous unions at class
> scope certainly are.

I agree. That needs to be fixed.
Top | Discussion index | About this forum | D home