Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When calling a static function from an inherited script, subcalls are not dispatched to the inheriting script's functions #62998

Closed
BimDav opened this issue Jul 14, 2022 · 4 comments

Comments

@BimDav
Copy link
Contributor

BimDav commented Jul 14, 2022

Godot version

3.4.4-stable, 4.0 alpha 11

System information

Windows 10

Issue description

In parent.gd:

extends Node
static func get_number() -> int:
    return 0

static func get_next_number() -> int:
    return get_number() + 1

In child.gd:

extends "res://parent.gd"
static func get_number() -> int:
    return 1

Calling load("res://child.gd").get_next_number() returns 1, while it should return 2.

Following the calls in a c++ debugger, it seems that when we are inside the parent's get_next_number(), all information about child is lost.

Steps to reproduce

Run the provided sample project

Minimal reproduction project

test_static_inheritance.zip

@ProbDenis
Copy link
Contributor

I can confirm that this is still an issue in 4.1.1.
It limits the usefulness of static functions, and I have to use a few ugly workarounds when using child classes that override static functions.

@shrubbgames
Copy link

I just ran into this in 4.2.1 as well.

@AThousandShips
Copy link
Member

I'm not convinced this is a bug, static functions can't be inherited and there's no reason to assume the static function being called should take into account what the class itself is, this isn't how it works in at least c++ I don't know about other languages

@AThousandShips
Copy link
Member

Thank you for reporting, consolidating in:

This has more details and some commentary

See there for more details, if you think something was missed about this and it's not the same issue, please comment here and it can be reopened

@AThousandShips AThousandShips closed this as not planned Won't fix, can't repro, duplicate, stale Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants