SpacemanDMM
SpacemanDMM copied to clipboard
Should overridden procs inherit parent return type?
/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?
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.