-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
GDScript: Improve call analysis #75988
GDScript: Improve call analysis #75988
Conversation
Notes from the GDScript meeting:
|
daf2e20
to
af6d89f
Compare
I removed the |
06cfa39
to
ce9c682
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small typo noticed, and needs a rebase, but is there a reason this hasn't been merged? It feels like it's good to go otherwise :)
modules/gdscript/tests/scripts/analyzer/warnings/unsafe_call_argument.gd
Show resolved
Hide resolved
ce9c682
to
8227ea1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just noticed some discrepancies in whether mark_node_unsafe
should be protected by #ifdef DEBUG_ENABLED
compared to existing code. I didn't do a thorough review of the analyzer, but I believe there's an existing pattern that isn't being followed here that could have unintended consequences?
@@ -4838,18 +4838,33 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p | |||
|
|||
if ((arg_type.is_variant() || !arg_type.is_hard_type()) && !(par_type.is_hard_type() && par_type.is_variant())) { | |||
// Argument can be anything, so this is unsafe. | |||
#ifdef DEBUG_ENABLED | |||
mark_node_unsafe(p_call->arguments[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So all of the push_warning()
that I saw in the analyzer were protected by DEBUG_ENABLED
, but none of the mark_node_unsafe()
calls were. I think it might make sense to pull this one outside the #ifdef
block here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
godot/modules/gdscript/gdscript_analyzer.cpp
Lines 5117 to 5127 in f6bf51c
void GDScriptAnalyzer::mark_node_unsafe(const GDScriptParser::Node *p_node) { | |
#ifdef DEBUG_ENABLED | |
if (p_node == nullptr) { | |
return; | |
} | |
for (int i = p_node->start_line; i <= p_node->end_line; i++) { | |
parser->unsafe_lines.insert(i); | |
} | |
#endif | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hahahahah, well, that resolves it as not mattering for sure :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
8227ea1
to
ac0db30
Compare
UNSAFE_CALL_ARGUMENT
warning
I extended this PR. Please remove the |
ac0db30
to
10373d6
Compare
Should you remove this code too? godot/modules/gdscript/gdscript_analyzer.cpp Lines 634 to 638 in e188d61
|
Moved the milestone to 4.2, as we entered yesterday the release freeze for 4.1, where only urgent bugfixes are merged. Added the "cherrypick 4.1" tag as this would be interesting to patch 4.1.x with your PR. |
10373d6
to
e1e0908
Compare
e1e0908
to
1cf0775
Compare
The GDScript team thinks that this PR should be merged for 4.2. We should take a look again at this before the feature freeze. |
* Add missing `UNSAFE_CALL_ARGUMENT` warning. * Fix `Object` constructor. * Display an error for non-existent static methods.
1cf0775
to
e8696f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me.
@@ -24,7 +24,8 @@ func test(): | |||
print(StringName("hello")) | |||
print(NodePath("hello/world")) | |||
var node := Node.new() | |||
print(RID(node)) | |||
@warning_ignore("unsafe_call_argument") | |||
print(RID(node)) # TODO: Why is the constructor (or implicit cast) not documented? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with this comment? https://docs.godotengine.org/en/stable/classes/class_rid.html#class-rid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no RID(Object)
constructor (or something like this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, we should document the explicit conversion.
Thanks! |
UNSAFE_CALL_ARGUMENT
warning.