[Bug] contravariant return types

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] contravariant return types

Post by Khan » Sat Sep 18, 2004 2:34 pm

The following Code should not compile for obvious reasons but does.

Code: Select all

interface ReturnTest
	func String gimmeString()
end

class ShouldNotWork implements ReturnTest
	func new()
	end

	func object gimmeString()
		return ShouldNotWork.new()
	end
end

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

Post by Dragonlord » Sat Sep 18, 2004 2:39 pm

=> moved to DragonScript Bugs.

bug verified. the check on the return type is only done on functions imported from the base class but got lost on those from interfaces in certain situations.
fixing this bug will be done together with a small rework of the parser for native classes.
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