[Bug] Argument subtypes and interfaces

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
[Bug] Argument subtypes and interfaces

Post by Khan » Sat Sep 25, 2004 10:44 am

There is a strange problem with the current svn snapshot

Code: Select all

interface Addable
	func void add(Object o)
end

class Add implements Addable
	func new()
	end

	func void add(Object o)
	end
end


class POC extends Application
	func new()
	end
	
	func int run()
		var String s = "w007"
		var Add a = Add.new()
		a.add(s)
		return 0
	end
end
Does not compile
[E#39] poc.ds(39,5): Function add(String) not found in Add. Possible candidates:
function Add.add(Object)
function Add.add(Object)
[DS] Compilation failed: Errors(1), Warnings(0).
If you remove the interface, everthing is ok.

For earlier versions (beginning of this week) this code worked. So you probably screwed something up in the last few days. Might have something to do with renaming object to Object.

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

Post by Dragonlord » Sat Sep 25, 2004 7:36 pm

like i stated in the last icq message a couple days ago (before the server upgrade took place). the parser checks if functions are ambigious by going through the function list of a class and checks if it finds only one matching function. after the last update to fix certain problems the very same function is allowed now more than once.

the fix is simple, i just had no time to do it right now because the stupid USB crap here keeps me busy. but this should be fixed tomorrow most probably.
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 » Sun Sep 26, 2004 3:29 pm

fixed
Image
Oh to be a dragon, of silkworm size or immense...

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

Post by Khan » Mon Sep 27, 2004 11:03 am

Uh well, fixed, but I can't check anymore if a reference is null :cry:

Code: Select all

someObject != null
doesn't work anymore.

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

Post by Dragonlord » Mon Sep 27, 2004 3:57 pm

that is correct like this.

i've changed the system so that Object owns the operator '==' which checks for equality and has to be overloaded by derived classes (together with hashCode) instead of 'equals'.

now arises a problem. if I also put '!=' as operator in Object any derived class would have to overload both '==' and '=!' because any piece of code might use '==' or '!=' to check for equality situations. in my eyes that's a rather nasty thing as you need to implement this equality check twice.

thus I decided to not use '!=' on Object so you don't have to double-implement the check. to get around this use 'not obj == null'.

i donno how you see this Khan but in favor of not doule-implement code I would drop '!='.

EDIT: ähm... eventuelly this is 'not (obj == null)' as i think the precedance ordering of 'not' is currently a bit fucked up.

EDIT: EDIT: possible solution, implement '!=' in Object as 'return not ==(obj)'. this would allow people to be lazy without braking things.
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