GDScript: Improve error message for static/non-static function conflicts#117965
GDScript: Improve error message for static/non-static function conflicts#117965Lidang-Jiang wants to merge 1 commit intogodotengine:masterfrom
Conversation
Signed-off-by: Lidang-Jiang <lidangjiang@gmail.com>
There was a problem hiding this comment.
This is overcomplicated. You don't need to add code to check_class_member_name_conflict(), and you don't necessarily need to increase the indentation level in the if (!valid) branch (even though it means the function signature line is being generated in vain). Also, I have a PR #117360 on unifying signature handling, so I could add a more precise error message there.
There was a problem hiding this comment.
Thanks for the review! You're right, this is overcomplicated. Since you already have #117360 for unifying signature handling and could add a more precise error message there, I'm happy to close this PR and defer to your approach. Let me know if you'd prefer that.
There was a problem hiding this comment.
Please avoid creating multiple small files to test related features/bugs/warnings. Analyzer and runtime tests support multiple errors. Try to create comprehensive tests.
There was a problem hiding this comment.
Good point, will consolidate into a single comprehensive test file if this PR continues.
Fixes #117912.
When a child class defines a function with the same name as a parent's static function (or vice versa), the error messages were not specific enough about the static/non-static mismatch.
Changes:
In
check_class_member_name_conflict: When a member name conflicts with a parent class's static function, the error now saysThe member "X" already exists in parent class Y as a static function.instead of the genericThe member "X" already exists in parent class Y.In
resolve_function_signature: Split the validation into two cases:The function "X" is not static, but the parent function of the same name is static.Before
After
Tests added:
override_static_function_with_non_static.gd/.outoverride_non_static_function_with_static.gd/.outvariable_overloads_superclass_static_function.gd/.outAI disclosure: AI tooling (Claude Code) was used to assist with writing and reviewing the code. All modifications were reviewed and tested by the author.