referencing non-static stuff from static context

Found a bug in the language, the VM or the compiler? help us iron things out or give ideas for doing things better.
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
User avatar
Khan
Intermediate
Posts:69
Joined:Fri Sep 17, 2004 9:31 am
Location:src/packages/collections/
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
referencing non-static stuff from static context

Post by Khan » Tue Sep 28, 2004 11:01 am

Dragonlord, you should definitely get up earlier so I don't have to post here ;)

The stuff that comes here is about catching coder stupidity at compiletime, so diffrent views are possible. Just remenber, static type stystems are about catching coder stupidity at compiletime.

Code: Select all

class StaticStuff
	var String s

	func new()
		s = "initialzed"
	end

	public static func void message1()
		System.print("StaticStuff.message1()\n")
		System.print(this.s+"\n")
	end
end
As implemented correctly by you, from a static context no non-static stuff can be referenced. So whenever you invoke message1() - even on an StaticStuff instance - it will result in a ENullPointer. But the compiler/parser doesn't catch this.

User avatar
Dragonlord
Forum Administrator
Posts:609
Joined:Fri Jul 30, 2004 4:30 pm
Location:Switzerland
Contact:

Post by Dragonlord » Tue Sep 28, 2004 3:23 pm

kinda strange. the parser has a check for member access and should deny access to this/super inside static functions. looks like some check function did not trasnfer the check request over to it's child (checking arguments is done using child objects of the code checker). i'll look into that one.

it's good that the engine just bailed out with null pointer exception instead of dying... that's already a success ;)

and i was not sleeping... i was in the city to do some payments.
Image
Oh to be a dragon, of silkworm size or immense...

User avatar
Dragonlord
Forum Administrator
Posts:609
Joined:Fri Jul 30, 2004 4:30 pm
Location:Switzerland
Contact:

Post by Dragonlord » Tue Sep 28, 2004 3:37 pm

fixed that one. the error only occured using 'this.s'. if used as 's' only the error was detected and reported. now things play again like they should.
Image
Oh to be a dragon, of silkworm size or immense...

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable