Add warnings for shadowed @GDScriptand @GlobalScope functions#106987
Open
EdwardChanCH wants to merge 1 commit intogodotengine:masterfrom
Open
Add warnings for shadowed @GDScriptand @GlobalScope functions#106987EdwardChanCH wants to merge 1 commit intogodotengine:masterfrom
@GDScriptand @GlobalScope functions#106987EdwardChanCH wants to merge 1 commit intogodotengine:masterfrom
Conversation
Contributor
Author
|
Discovered more bugs:
Edit: Fixed. |
aa1a41a to
d8801db
Compare
431b30e to
93ed582
Compare
@GDScript and @GlobalScope
2384e63 to
4e01b99
Compare
Contributor
Author
|
Thanks for removing the 29 extra team reviews, not sure what happened there... |
dalexeev
reviewed
Mar 11, 2026
Contributor
Author
|
Below is a full summary of what this PR fixed: @warning_ignore_start("unused_parameter", "unused_variable", "unused_signal", "untyped_declaration", "inferred_declaration")
class_name ceil # Missing warning. <-- Too complex to fix in this PR.
extends Node
class floor extends Node: # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
func f() -> void:
pass
var sin = 111 # (SHADOWED_GLOBAL_IDENTIFIER)
const cos = 222 # (SHADOWED_GLOBAL_IDENTIFIER)
# Named enum identifier do not shadow anything, because it can only be accessed as NamedEnum.EnumIdentifier.
enum max { # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
min = 333 # No warning as expected.
}
enum {
clamp, # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
clampi = 444 # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
}
# Note: Signal parameter do not shadow anything.
signal sqrt # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
signal s(pow) # No warning as expected.
func get(_property: StringName) -> Variant: # (NATIVE_METHOD_OVERRIDE)
return 100
func char(code :int): # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
return 200
func log(x: float): # Missing warning. <-- Fixed! Now warns (SHADOWED_GLOBAL_IDENTIFIER)
return 300
func unique(log: float): # (SHADOWED_GLOBAL_IDENTIFIER)
return 400
func unique2(...log): # (SHADOWED_GLOBAL_IDENTIFIER)
return 500
# Note: Named lambdas do not override anything.
# No warning as expected.
var named_lambda_1 = func get():
return null
# No warning as expected.
var named_lambda_2 = func char():
return null
# No warning as expected.
var named_lambda_3 = func log():
return null
var named_lambda_4 = func unique():
return null
func _ready() -> void:
var sinh = 1 # (SHADOWED_GLOBAL_IDENTIFIER)
for char in []: # (SHADOWED_GLOBAL_IDENTIFIER)
pass
var k = 1
match k:
var abs: # (SHADOWED_GLOBAL_IDENTIFIER)
pass
# The new warnings are consistent with how GDScript is parsed.
print(sin) # Prints 111
print(cos) # Prints 222
print(max) # Prints { "min": 333 }
print(min) # Prints @GlobalScope::min
print(max.min) # Prints 333
print(clamp) # Prints 0
print(clampi) # Prints 444
print(ceil) # Prints (res://main.gd):<GDScript#-9223372002226600493>
print(floor) # Prints ():<GDScript#-9223372002042051115>
print(sqrt) # Prints Node(main.gd)::[signal]sqrt
print(s) # Prints Node(main.gd)::[signal]s
|
Contributor
Author
Fixing this (in the future) will require changing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes: godotengine/godot-proposals#14425
Related: #106984
Note: Some previous code has been split into #117308 to keep this PR manageable.
Any help is appreciated!