Skip to content

[GDScript 2.0] Constants declared in a parent class cannot be used as typing type in an extended class #69586

@adamscott

Description

@adamscott

Godot version

4.0.dev (015dc49)

System information

Linux (Ubuntu 22.04), Vulkan, Radeon RX Vega 64 (eGPU)

Issue description

# a.gd
extends Resource
# base.gd
extends Resource
const A: = preload("res://a.gd")
# extend.gd
extends "base.gd"

static func test(a: A) -> void:
	print(A)

The editor will complain with this error in extend.gd: Error at (4, 19): "A" was not found in the current scope..

But removing the typing from test() (static func test(a) -> void:), the following line will print without any issues.
<GDScript#-9223372009658908249>

It's not possible too to declare something like const A: = preload("res://a.gd") inside extend.gd as it will result with this error: The member "A" already exists in parent class res://base.gd.

Extended classes should be able to use constants declared inside the base class the same way it is possible to use them inside that said base class.

Steps to reproduce

  1. Create a base class
  2. Create an extend class
  3. Declare a constant that preloads a class in the base class
  4. Try to use that constant as a type inside the extend class

Minimal reproduction project

69586.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions