Identifier "X" not declared in the current scope when referring to inherited class

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

I’m getting this error and I’m not sure why.
For simplicity’s sake, let’s assume I have two scripts: and looks as following:

class_name Animal
var name

class Cow extends Animal:
   func _init():
     name = "Cow"

class Sheep extends Animal:
   func _init():
     name = "Sheep"

and looks as following:

const Animal = preload(".../")
var animals : Array
func populate_farm():

I’m getting the following errors: Identifier "Cow" not declared in the current scope., Identifier "Sheep" not declared in the current scope.

I’m not sure if I’m doing something wrong, but I have no idea how else to do this. I also can’t find anything online that explains how to do this. Any help?

:bust_in_silhouette: Reply From: zhyrin

Here the inner classes only exist inside the scope of the Animal class.
If you want to access them (outside of the Animal class), use Animal.Cow etc.