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

Variable name shadowing class_name class doesn't trigger any error/warning #80003

Closed
acgc99 opened this issue Jul 29, 2023 · 0 comments · Fixed by #80587
Closed

Variable name shadowing class_name class doesn't trigger any error/warning #80003

acgc99 opened this issue Jul 29, 2023 · 0 comments · Fixed by #80587

Comments

@acgc99
Copy link

acgc99 commented Jul 29, 2023

Godot version

v4.1.stable.official [9704596]

System information

Godot v4.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 (NVIDIA; 31.0.15.3667) - Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz (8 Threads)

Issue description

If you define a class_name and then use the same name in a variable, no shadowing error/warning is triggered. This also create some bad references (see below).

Steps to reproduce

Just do something like:

class_name Foo
extends Control

var Foo: Foo

In another script you can also do:

extends Node

var Foo: Foo #= Foo.new() # this raises an error if uncommented: Parse Error: Could not resolve member "Foo": Cyclic reference


func _ready():
	Foo ## This refers to main.gd and not to the local variable

Minimal reproduction project

N/A

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

Successfully merging a pull request may close this issue.

3 participants