SpacemanDMM icon indicating copy to clipboard operation
SpacemanDMM copied to clipboard

Should overridden procs inherit parent return type?

Open DamianX opened this issue 4 years ago • 1 comments

/atom/proc/thing()
	RETURN_TYPE(/list)
	return list()
	
/atom/movable/thing()
	return list()

world/New()
	..()
	var/atom/movable/AM = new
	world.log << AM.thing().len
dungverbs.dm, line 38, column 25:
warning: field access requires static type: "len"
- 32:20: add a return type annotation to /atom/movable/proc/thing

I think it would make sense for /atom/movable/thing() to inherit /atom/proc/thing()'s RETURN_TYPE but maybe I'm missing something. Is this a bug or intended?

DamianX avatar Jul 01 '20 13:07 DamianX

It's arguably a hole in the design. The workaround is to repeat the RETURN_TYPE() statement in /atom/movable/thing() too. Ideally we would approach gradually a traditional OOP return type system including variance.

SpaceManiac avatar Jul 02 '20 23:07 SpaceManiac