Assigned value type (X) doesn't match the variable's type (X).

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SuperPrower

I have a script file with class_name “Outer” (for example). It doesn’t extend anything. In it, I have an inner class:

class Inner:
	var _q: int
	var _r: int
	
	func _init(q: int, r: int):
		...

Then, in other file, I try to create an instance of it. I don’t load or preload Outer script.

var inst: Outer.Inner = Outer.Inner.new(x, y)

And I get a following error:

Assigned value type (Inner) doesn't match the variable's type (Inner).

This doesn’t happen when I move Inner to a separate script file. What should I do about it? I don’t really need this class without Outer, so I feel like it’s logical to make it a nested class.

It looks like this should have worked. Maybe it’s a bug with inner classes and type hints.

Zylann | 2019-10-23 12:30