|
@@ -3300,7 +3300,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
|
|
|
}
|
|
|
|
|
|
Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
|
|
|
- //before parsing, try the usual stuff
|
|
|
+ // Before parsing, try the usual stuff.
|
|
|
if (ClassDB::class_exists(p_symbol)) {
|
|
|
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
|
|
|
r_result.class_name = p_symbol;
|
|
@@ -3534,16 +3534,24 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Must check GDScript functions after parsing to ensure functions like Array.max() are handled correctly.
|
|
|
+ bool function_in_gdscript_functions = false;
|
|
|
for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
|
|
|
- // this has to get run after parsing because otherwise functions like Array.max() will trigger it
|
|
|
if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) {
|
|
|
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
|
|
|
- r_result.class_name = "@GDScript";
|
|
|
- r_result.class_member = p_symbol;
|
|
|
- return OK;
|
|
|
+ function_in_gdscript_functions = true;
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Need special checks for assert, preload, and yield as they are technically
|
|
|
+ // keywords, so are not registered in GDScriptFunctions.
|
|
|
+ if (function_in_gdscript_functions || "yield" == p_symbol || "assert" == p_symbol || "preload" == p_symbol) {
|
|
|
+ r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
|
|
|
+ r_result.class_name = "@GDScript";
|
|
|
+ r_result.class_member = p_symbol;
|
|
|
+ return OK;
|
|
|
+ }
|
|
|
+
|
|
|
return ERR_CANT_RESOLVE;
|
|
|
}
|
|
|
|