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

Display correct symbol in warning when unique name is used without @onready annotation #102389

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion modules/gdscript/gdscript_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,12 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
}
}
if (is_get_node) {
parser->push_warning(member.variable, GDScriptWarning::GET_NODE_DEFAULT_WITHOUT_ONREADY, is_using_shorthand ? "$" : "get_node()");
String offending_syntax = "get_node()";
if (is_using_shorthand) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 variables: is_get_node and is_using_shorthand. Are you sure that this is the correct one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding was that is_using_shorthand was used for when the $ or % prefix was used, rather than a call to the get_node method:

# In all of these, is_get_node = true
var a = get_node("Node2D")  # is_using_shorthand = false
var b = $Node2D             # is_using_shorthand = true
var c = %Node2D             # is_using_shorthand = true

Since in all of these cases, is_get_node is true, we start out by checking it - then, we change the string to output to one of the shorthand versions if is_using_shorthand is true as well.

GDScriptParser::GetNodeNode *get_node_node = static_cast<GDScriptParser::GetNodeNode *>(expr);
offending_syntax = get_node_node->use_dollar ? "$" : "%";
}
parser->push_warning(member.variable, GDScriptWarning::GET_NODE_DEFAULT_WITHOUT_ONREADY, offending_syntax);
}
}
}
Expand Down