From a23fc45727544142cc15e7ab96596b159a5bac42 Mon Sep 17 00:00:00 2001 From: George Marques Date: Wed, 26 May 2021 15:33:18 -0300 Subject: [PATCH] GDScript: Fix function signature check for self calls --- modules/gdscript/gdscript_analyzer.cpp | 2 ++ .../scripts/analyzer/features/call_self_get_name.gd | 9 +++++++++ .../scripts/analyzer/features/call_self_get_name.out | 3 +++ 3 files changed, 14 insertions(+) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.out diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 7b049592278..c0e24b80cd5 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2059,9 +2059,11 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool is_awa if (p_call->is_super) { base_type = parser->current_class->base_type; + base_type.is_meta_type = false; is_self = true; } else if (callee_type == GDScriptParser::Node::IDENTIFIER) { base_type = parser->current_class->get_datatype(); + base_type.is_meta_type = false; is_self = true; } else if (callee_type == GDScriptParser::Node::SUBSCRIPT) { GDScriptParser::SubscriptNode *subscript = static_cast(p_call->callee); diff --git a/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.gd b/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.gd new file mode 100644 index 00000000000..d21d8bce96b --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.gd @@ -0,0 +1,9 @@ +extends Node + +func test(): + set_name("TestNodeName") + if get_name() == &"TestNodeName": + print("Name is equal") + else: + print("Name is not equal") + print(get_name() is StringName) diff --git a/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.out b/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.out new file mode 100644 index 00000000000..dc4348d9c36 --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/call_self_get_name.out @@ -0,0 +1,3 @@ +GDTEST_OK +Name is equal +True