Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain usage of enums causes circular dependencies in a really unintuitive and hard-to-diagnose way. #45894

Closed
sniggyfigbat opened this issue Feb 11, 2021 · 2 comments

Comments

@sniggyfigbat
Copy link

Godot version:
v3.2.3-stable_mono_64

OS/device including version:
Windows 10 v190431.746

Issue description:
Usage of enums when prefaced by the class name causes circular dependencies, presumably because the script believes it's trying to load itself. Generally, paying attention to the autofill will guide users in the right direction (although it's a SUPER easy mistake to make), but when used in inner classes the autofill is explicitly wrong. Worst of all, there is no indication of illegal usage and the issue is only flagged when the script is loaded in somewhere else.

Steps to reproduce:
Simply put the following code into any project. It's so basic I haven't bothered with a project file.

# test.gd
extends Resource
class_name GeneralTest

enum TestEnum { T1, T2, T3 }

# Called when the node enters the scene tree for the first time.
func _ready():
	# Works:
	var whatever1 : int = TestEnum.T2
	
	# Looks like it should work, but actually causes
	# circular dependency, and gives no indication of it:
	var whatever2 : int = GeneralTest.TestEnum.T2

class InnerClass:
	# Works, but doesn't autocomplete, which leads user
	# to not expect it to work:
	var inner_whatever1 : int = TestEnum.T1
	
	# DOES autocomplete, leading user to expect it to work,
	# but actually causes circular dependency with no indication.	
	var inner_whatever2: int = GeneralTest.TestEnum.T1
# literally_anywhere_else.gd
extends Node
var example : GeneralTest # THIS is the line that starts complaining about circular dependencies.
@Calinou
Copy link
Member

Calinou commented Feb 11, 2021

Duplicate of #21461.

@sniggyfigbat
Copy link
Author

...Is it? It's specific, whereas that thread is super-general. I guess it appears to be part of the same body of problems, admittedly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants