This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Edit:
Current workaround from https://github.com/godotengine/godot/issues/69050 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.

Godot version 4 beta 5
in Engine by (13 points)
edited by

1 Answer

+1 vote

I have the same issue. Even stranger is that InventoryBase.new() does get recognized. I opened an issue for this here: https://github.com/godotengine/godot/issues/69050

by (25 points)
edited by

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.