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

Calling super() in _init() when the base class does not define an _init() runs without issue in 4.1.2.stable but causes a parse error in 4.1.3.stable #84850

Closed
blujai831 opened this issue Nov 13, 2023 · 7 comments

Comments

@blujai831
Copy link

blujai831 commented Nov 13, 2023

Godot version

4.1.3.stable

System information

Godot v4.1.3.stable - Manjaro Linux #1 SMP PREEMPT_DYNAMIC Thu Nov 9 03:01:44 UTC 2023 - X11 - Vulkan (Forward+) - integrated AMD Radeon Vega 10 Graphics (RADV RAVEN) () - AMD Ryzen 7 3750H with Radeon Vega Mobile Gfx (8 Threads)

Issue description

Calling super() in _init() when the base class does not define an _init() runs without issue in 4.1.2.stable but causes a parse error in 4.1.3.stable.

As I'm not an expert on Godot internals and don't know whether internal classes expose any function to GDScript as _init() (though a quick ag on my end suggests they do not), I can't say whether I expect this to work on 4.1.3.stable, or to not work on 4.1.2.stable, but either way, this seems to be a breaking change.

Steps to reproduce

The following GDScript code compiles and runs without issue in 4.1.2.stable, but in 4.1.3.stable, it causes a parse error and will neither compile nor run:

class_name MyNode extends Node
func _init() -> void:
    super()

Minimal reproduction project

repro.zip

@YuriSizov
Copy link
Contributor

This seems to be expected, this check was added on purpose in #81808. cc @anvilfolk @adamscott

@AThousandShips
Copy link
Member

AThousandShips commented Nov 13, 2023

You still got an error when running in 4.1.2, see:

@blujai831
Copy link
Author

In 4.1.2 the error does not occur for _init specifically.

@AThousandShips
Copy link
Member

So it won't have any problems when running the code?

@blujai831
Copy link
Author

That's right. Pretty bizarre.

@AThousandShips
Copy link
Member

Well then it is an exception to an otherwise valid rule, worth to keep safe with the other cases, so change is intentional and necessary

@anvilfolk
Copy link
Contributor

Yes, I'm in agreement that this was an intentional change! 😊

The idea is that if the GDScript user wrote a super() call expecting it to do something, but we can guarantee it will be a no-op since there is no base class method to call, then we should warn the user that there's some mismatch between what they intended to do and what is actually going to happen!

Hope that makes sense! If it does, I'd recommend closing the issue :)

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

4 participants