www.digitalmars.com         C & C++   DMDScript  

D - [BUG] compiler: need 'this'

reply Ant <duitoolkit yahoo.ca> writes:
this does not compile:


class C
{
	this()
	{
		f();
	}
	
	static {
		void f(int i)
		{
		}
	}
	
	void f()
	{
	}
	
	// 

	void ff()
	{
		f();
	}
}

int main(char[][] args)
{
	return 0;
}

$ dmd OneNotZero.d -I~/dmd/src/phobos
OneNotZero.d(5): need 'this' to access member f

if the static method f is defined after
the non static method f compiles OK

I found this when the compiler issued the message:
"./leds/ProjectTarget.d(664): Error: expected 1 arguments, not 0"
on a similar situation

Ant
Apr 04 2004
parent reply C <dont respond.com> writes:
Yea ive never seen static { } , I dont think that should be allowed ( or=
 =

is that the bug your reporting ? )

This compiles though

class C
{
	this()
	{
		f();
	}

	static void f(int i)
	{
	}
	=


	void f()
	{
	}

//

	void ff()
	{
		f();
	}
}

int main(char[][] args)
{
	return 0;
}


On Sun, 04 Apr 2004 21:05:07 -0400, Ant <duitoolkit yahoo.ca> wrote:

 this does not compile:


 class C
 {
 	this()
 	{
 		f();
 	}
 	=
 	static {
 		void f(int i)
 		{
 		}
 	}
 	=
 	void f()
 	{
 	}
 	=
 	//

 	void ff()
 	{
 		f();
 	}
 }

 int main(char[][] args)
 {
 	return 0;
 }

 $ dmd OneNotZero.d -I~/dmd/src/phobos
 OneNotZero.d(5): need 'this' to access member f

 if the static method f is defined after
 the non static method f compiles OK

 I found this when the compiler issued the message:
 "./leds/ProjectTarget.d(664): Error: expected 1 arguments, not 0"
 on a similar situation

 Ant
-- = D Newsgroup.
Apr 04 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Sun, 04 Apr 2004 22:44:49 -0700, C wrote:

 Yea ive never seen static { } , I dont think that should be allowed ( or 
 is that the bug your reporting ? )
 
 This compiles though
No, it does not for me, maybe platfom it's specific I'm on linux dmd 0.81. you can have for all the modifiers: static: from now on (maybe not with static but works for others) and static one member and static {} the block Ant
 
 class C
 {
 	this()
 	{
 		f();
 	}
 
 	static void f(int i)
 	{
 	}
 	
 
 	void f()
 	{
 	}
 
 //
 
 	void ff()
 	{
 		f();
 	}
 }
 
 int main(char[][] args)
 {
 	return 0;
 }
 
 
 On Sun, 04 Apr 2004 21:05:07 -0400, Ant <duitoolkit yahoo.ca> wrote:
 
 this does not compile:


 class C
 {
 	this()
 	{
 		f();
 	}
 	
 	static {
 		void f(int i)
 		{
 		}
 	}
 	
 	void f()
 	{
 	}
 	
 	//

 	void ff()
 	{
 		f();
 	}
 }

 int main(char[][] args)
 {
 	return 0;
 }

 $ dmd OneNotZero.d -I~/dmd/src/phobos
 OneNotZero.d(5): need 'this' to access member f

 if the static method f is defined after
 the non static method f compiles OK

 I found this when the compiler issued the message:
 "./leds/ProjectTarget.d(664): Error: expected 1 arguments, not 0"
 on a similar situation

 Ant
Apr 04 2004
next sibling parent reply C <dont respond.com> writes:
Hmm, it works for me using .82, maybe try that ?

 you can have for all the modifiers:

 static:		from now on (maybe not with static but works for others)
 and
 static		one member
 and
 static {}	the block
Cool! C On Mon, 05 Apr 2004 01:15:45 -0400, Ant <duitoolkit yahoo.ca> wrote:
 On Sun, 04 Apr 2004 22:44:49 -0700, C wrote:

 Yea ive never seen static { } , I dont think that should be allowed (=
or
 is that the bug your reporting ? )

 This compiles though
No, it does not for me, maybe platfom it's specific I'm on linux dmd 0.81. you can have for all the modifiers: static: from now on (maybe not with static but works for others) and static one member and static {} the block Ant
 class C
 {
 	this()
 	{
 		f();
 	}

 	static void f(int i)
 	{
 	}
 	=
 	void f()
 	{
 	}

 //

 	void ff()
 	{
 		f();
 	}
 }

 int main(char[][] args)
 {
 	return 0;
 }


 On Sun, 04 Apr 2004 21:05:07 -0400, Ant <duitoolkit yahoo.ca> wrote:

 this does not compile:


 class C
 {
 	this()
 	{
 		f();
 	}
 	=
 	static {
 		void f(int i)
 		{
 		}
 	}
 	=
 	void f()
 	{
 	}
 	=
 	//

 	void ff()
 	{
 		f();
 	}
 }

 int main(char[][] args)
 {
 	return 0;
 }

 $ dmd OneNotZero.d -I~/dmd/src/phobos
 OneNotZero.d(5): need 'this' to access member f

 if the static method f is defined after
 the non static method f compiles OK

 I found this when the compiler issued the message:
 "./leds/ProjectTarget.d(664): Error: expected 1 arguments, not 0"
 on a similar situation

 Ant
-- = D Newsgroup.
Apr 04 2004
parent reply Ant <duitoolkit yahoo.ca> writes:
On Sun, 04 Apr 2004 23:33:23 -0700, C wrote:

 Hmm, it works for me using .82, maybe try that ?
Sorry I mean: linux .82 maybe it's a linux only bug. or are you on linux? (some times I'm the first to complain about the new dmd release, you really thought I wasn't at 82?... ;) Ant
Apr 04 2004
parent C <dont respond.com> writes:
 (some times I'm the first to complain about the new
 dmd release, you really thought I wasn't at 82?... ;)
lol good point. No im on windows, but unless its a linking error it see= ms = really odd that that would fail on linux, but succeed on windows. <shrug=

But I do get the same error message ( f.d(5): need 'this' to access memb=
er =

f ) when using the static { } block, which seems like a bug.

C

On Mon, 05 Apr 2004 01:36:27 -0400, Ant <duitoolkit yahoo.ca> wrote:

 On Sun, 04 Apr 2004 23:33:23 -0700, C wrote:

 Hmm, it works for me using .82, maybe try that ?
Sorry I mean: linux .82 maybe it's a linux only bug. or are you on linux? (some times I'm the first to complain about the new dmd release, you really thought I wasn't at 82?... ;) Ant
-- = D Newsgroup.
Apr 04 2004
prev sibling parent reply "Phill" <phill pacific.net.au> writes:
 you can have for all the modifiers:

 static: from now on (maybe not with static but works for others)
 and
 static one member
 and
 static {} the block
Is this just a new feature? I didnt know D had static blocks, good news! Phill. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.648 / Virus Database: 415 - Release Date: 3/31/2004
Apr 04 2004
parent Ant <Ant_member pathlink.com> writes:
In article <c4qrut$2juj$1 digitaldaemon.com>, Phill says...
 you can have for all the modifiers:

 static: from now on (maybe not with static but works for others)
 and
 static one member
 and
 static {} the block
Is this just a new feature? I didnt know D had static blocks, good news! Phill.
I just check to confirm I'm not going crazy. http://www.digitalmars.com/d/attribute.html All attributes can use the 3 forms including: static{}else{} Ant
Apr 05 2004