Open jdeppe-pivotal opened 9 months ago
What if you call super._to_string()
? Why would you call the non-virtual one?
AFAIK super
only works for the current method, not any other method, in this case it doesn't matter since to_string
naturally invokes the virtual method as designed
This is a limitation where built-in methods can't be accessed with super
, in this case the proper method would be to call super()
here, but it can't be done as Sprite2D
doesn't have a _to_string
as such, this is a limitation and I think it has been reported elsewhere but can't find it right now
See also:
That would require the engine to detect that to_string
calls _to_string
, how would that work?
If instead you call the virtual method by super it does error, arguably you could warn whenever super
is used with a non-virtual method, or a built-in one, where it doesn't have any effect
Tested versions
4.2.stable
System information
MacOS
Issue description
I'd like to customize the string representation of a class using the default representation plus my own message. So my class contains:
However, this results in a stack overflow because of infinite recursion. Also tried using (self as Object).to_string() with the same result. From a purely OO POV I'd expect this to be possible.
Steps to reproduce
As above
Minimal reproduction project (MRP)
None