const script resource defined in parent class not found in child class's scope

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

Edit:
Current workaround from Inner classes are not recognized as type in extended classes. · Issue #69050 · godotengine/godot · GitHub until it gets patched. Append a ParentClass

extends "res://Scripts/Parent.gd"

const Parent = preload("res://Scripts/Parent.gd")

func Init(_inventory:Parent.InventoryBase):
    // Do something
...

Original question:

Important note: This error only appeared when I migrated my project from v3.5 stable to v4.0 beta 5

I get the following error in my code in my child class

Parse Error: “InventoryBase” was not found in the current scope.

Parent class (InventoryDisplay.gd):

extends Node

const InventoryBase = preload("res://Scripts/InventoryBase.gd")
...

Child class (InventoryDisplay_Player.gd):

extends "res://Scripts/InventoryDisplay.gd"

func Init(_inventory:InventoryBase):
	m_Inventory = _inventory
...
      
  • InventoryBase is just a script that extends the Object type in Godot.

  • I have no issue in my parent class and when I try to define
    const InventoryBase = preload(“res://Scripts/InventoryBase.gd”)
    in my child class it shows this error instead

The member "InventoryBase" already exists in a parent class.

I’m not sure if I am missing anything, please advice.

:bust_in_silhouette: Reply From: JensRenders

I have the same issue. Even stranger is that InventoryBase.new() does get recognized. I opened an issue for this here: Inner classes are not recognized as type in extended classes. · Issue #69050 · godotengine/godot · GitHub

Good to know I’m not alone, thanks for the link to the github page

JustHallowed | 2022-11-25 10:09