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

GDScript 2.0: Typed assigning an inner class leads to a runtime error #67547

Closed
MikeSchulze opened this issue Oct 17, 2022 · 1 comment · Fixed by #68374
Closed

GDScript 2.0: Typed assigning an inner class leads to a runtime error #67547

MikeSchulze opened this issue Oct 17, 2022 · 1 comment · Fixed by #68374

Comments

@MikeSchulze
Copy link

Godot version

v4.0.beta3.official [01ae26d]

System information

Windows 10

Issue description

I have a function auto_free(<instance>) : Object to register instances to be get auto freed after test execution on my plugin GdUnit3.

The function signature is
func auto_free(obj) -> Object:
and returns the same obj

When going back to the original class, an error occurs at runtime
var instance :AdvancedTestClass.AtmosphereData = auto_free(AdvancedTestClass.AtmosphereData.new())
Trying to assign value of type '' to a variable of type 'AdvancedTestClass.gd'.

Steps to reproduce

Copy this code and run it.

class_name TestScene
extends Node

class Custom:
	pass

func _ready():
	test_wrapper()

func test_wrapper():
	# with this inner class it works
	var original: = TestScene.Custom.new()
	var as_object :TestScene.Custom = auto_free(original)
	prints(as_object)
	
	# with this inner class defined in ExampleClass it breaks
	var original_: = ExampleClass.Data.new()
	# this line fails at runtime
	var as_object_ :ExampleClass.Data = auto_free(original_)

# just return same value 
func auto_free(value :Object) -> Object:
	return value

The external script/class

class_name ExampleClass
extends Resource

class Data:
	pass

Minimal reproduction project

No response

@Calinou Calinou changed the title GdScript 2.0: Typed assigning an inner class leads to a runtime error GDScript 2.0: Typed assigning an inner class leads to a runtime error Oct 17, 2022
@rune-scape
Copy link
Contributor

just tested that this was an issue on beta 3 and that it's fixed as of #68374 @akien-mga

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants