|
@@ -69,11 +69,11 @@ static MethodInfo info_from_utility_func(const StringName &p_function) {
|
|
|
} else {
|
|
|
for (int i = 0; i < Variant::get_utility_function_argument_count(p_function); i++) {
|
|
|
PropertyInfo pi;
|
|
|
-#ifdef DEBUG_METHODS_ENABLED
|
|
|
+#ifdef DEBUG_ENABLED
|
|
|
pi.name = Variant::get_utility_function_argument_name(p_function, i);
|
|
|
#else
|
|
|
pi.name = "arg" + itos(i + 1);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
pi.type = Variant::get_utility_function_argument_type(p_function, i);
|
|
|
info.arguments.push_back(pi);
|
|
|
}
|
|
@@ -452,7 +452,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
|
|
|
if (!parser->_is_tool && ext_parser->get_parser()->_is_tool) {
|
|
|
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
base = ext_parser->get_parser()->head->get_datatype();
|
|
|
} else {
|
|
@@ -486,7 +486,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
|
|
|
if (!parser->_is_tool && base_parser->get_parser()->_is_tool) {
|
|
|
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
base = base_parser->get_parser()->head->get_datatype();
|
|
|
}
|
|
@@ -513,7 +513,7 @@ Error GDScriptAnalyzer::resolve_class_inheritance(GDScriptParser::ClassNode *p_c
|
|
|
if (!parser->_is_tool && info_parser->get_parser()->_is_tool) {
|
|
|
parser->push_warning(p_class, GDScriptWarning::MISSING_TOOL);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
base = info_parser->get_parser()->head->get_datatype();
|
|
|
} else if (class_exists(name)) {
|
|
@@ -1039,7 +1039,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
switch (member.type) {
|
|
|
case GDScriptParser::ClassNode::Member::VARIABLE: {
|
|
|
bool previous_static_context = static_context;
|
|
@@ -1102,7 +1102,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
} break;
|
|
|
case GDScriptParser::ClassNode::Member::CONSTANT: {
|
|
|
check_class_member_name_conflict(p_class, member.constant->identifier->name, member.constant);
|
|
@@ -1132,7 +1132,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
|
|
|
if (param->datatype_specifier == nullptr) {
|
|
|
parser->push_warning(param, GDScriptWarning::UNTYPED_DECLARATION, "Parameter", param->identifier->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
mi.arguments.push_back(param_type.to_property_info(param->identifier->name));
|
|
|
// Signals do not support parameter default values.
|
|
|
}
|
|
@@ -1185,7 +1185,7 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
|
|
|
if (member.m_enum->identifier->name == StringName()) {
|
|
|
is_shadowing(element.identifier, "enum member", false);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
current_enum = prev_enum;
|
|
@@ -1273,7 +1273,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|
|
if (!p_class->resolved_interface) {
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
bool has_static_data = p_class->has_static_data;
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (!parser->has_class(p_class)) {
|
|
|
if (parser_ref.is_null()) {
|
|
@@ -1322,7 +1322,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|
|
has_static_data = member.m_class->has_static_data;
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
#ifdef DEBUG_ENABLED
|
|
@@ -1336,7 +1336,7 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
|
|
|
}
|
|
|
parser->push_warning(static_unload ? static_unload : p_class, GDScriptWarning::REDUNDANT_STATIC_UNLOAD);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1443,7 +1443,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
|
|
|
if (member.variable->usages == 0 && String(member.variable->identifier->name).begins_with("_")) {
|
|
|
parser->push_warning(member.variable->identifier, GDScriptWarning::UNUSED_PRIVATE_CLASS_VARIABLE, member.variable->identifier->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (member.variable->property == GDScriptParser::VariableNode::PROP_SETGET) {
|
|
|
GDScriptParser::FunctionNode *getter_function = nullptr;
|
|
@@ -1477,7 +1477,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
|
|
|
if (member.variable->datatype.builtin_type == Variant::INT && return_datatype.builtin_type == Variant::FLOAT) {
|
|
|
parser->push_warning(member.variable, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1503,7 +1503,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
|
|
|
if (member.variable->datatype.builtin_type == Variant::FLOAT && setter_function->parameters[0]->datatype.builtin_type == Variant::INT) {
|
|
|
parser->push_warning(member.variable, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1518,7 +1518,7 @@ void GDScriptAnalyzer::resolve_class_body(GDScriptParser::ClassNode *p_class, co
|
|
|
if (member.signal->usages == 0) {
|
|
|
parser->push_warning(member.signal->identifier, GDScriptWarning::UNUSED_SIGNAL, member.signal->identifier->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1662,7 +1662,7 @@ void GDScriptAnalyzer::resolve_annotation(GDScriptParser::AnnotationNode *p_anno
|
|
|
if (argument_info.type == Variant::INT && value.get_type() == Variant::FLOAT) {
|
|
|
parser->push_warning(argument, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (!Variant::can_convert_strict(value.get_type(), argument_info.type)) {
|
|
|
push_error(vformat(R"(Invalid argument for annotation "%s": argument %d should be "%s" but is "%s".)", p_annotation->name, i + 1, Variant::get_type_name(argument_info.type), argument->get_datatype().to_string()), argument);
|
|
@@ -1735,7 +1735,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|
|
if (function_name == StringName()) {
|
|
|
function_visible_name = p_is_lambda ? "<anonymous lambda>" : "<unknown function>";
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
for (int i = 0; i < p_function->parameters.size(); i++) {
|
|
|
resolve_parameter(p_function->parameters[i]);
|
|
@@ -1879,7 +1879,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|
|
if (native_base != StringName()) {
|
|
|
parser->push_warning(p_function, GDScriptWarning::NATIVE_METHOD_OVERRIDE, function_name, native_base);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
#endif // TOOLS_ENABLED
|
|
|
}
|
|
@@ -1888,7 +1888,7 @@ void GDScriptAnalyzer::resolve_function_signature(GDScriptParser::FunctionNode *
|
|
|
if (p_function->return_type == nullptr) {
|
|
|
parser->push_warning(p_function, GDScriptWarning::UNTYPED_DECLARATION, "Function", function_visible_name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
method_info.default_arguments.append_array(p_function->default_arg_values);
|
|
|
method_info.return_val = p_function->get_datatype().to_property_info("");
|
|
@@ -1984,7 +1984,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
|
|
|
parser->push_warning(p_assignable->identifier, GDScriptWarning::CONFUSABLE_LOCAL_DECLARATION, local.get_name(), p_assignable->identifier->name);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
GDScriptParser::DataType specified_type;
|
|
|
bool has_specified_type = p_assignable->datatype_specifier != nullptr;
|
|
@@ -2034,7 +2034,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
|
|
|
if (initializer_type.is_hard_type() && initializer_type.is_variant()) {
|
|
|
parser->push_warning(p_assignable, GDScriptWarning::INFERENCE_ON_VARIANT, p_kind);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
} else {
|
|
|
if (!initializer_type.is_set()) {
|
|
|
push_error(vformat(R"(Could not resolve type for %s "%s".)", p_kind, p_assignable->identifier->name), p_assignable->initializer);
|
|
@@ -2072,7 +2072,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
} else if (specified_type.builtin_type == Variant::INT && initializer_type.builtin_type == Variant::FLOAT) {
|
|
|
parser->push_warning(p_assignable->initializer, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -2104,7 +2104,7 @@ void GDScriptAnalyzer::resolve_assignable(GDScriptParser::AssignableNode *p_assi
|
|
|
parser->push_warning(p_assignable, GDScriptWarning::ENUM_VARIABLE_WITHOUT_DEFAULT, p_assignable->identifier->name);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
type.is_constant = is_constant;
|
|
|
type.is_read_only = false;
|
|
@@ -2122,7 +2122,7 @@ void GDScriptAnalyzer::resolve_variable(GDScriptParser::VariableNode *p_variable
|
|
|
}
|
|
|
}
|
|
|
is_shadowing(p_variable->identifier, kind, p_is_local);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant, bool p_is_local) {
|
|
@@ -2136,7 +2136,7 @@ void GDScriptAnalyzer::resolve_constant(GDScriptParser::ConstantNode *p_constant
|
|
|
}
|
|
|
}
|
|
|
is_shadowing(p_constant->identifier, kind, p_is_local);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::resolve_parameter(GDScriptParser::ParameterNode *p_parameter) {
|
|
@@ -2326,7 +2326,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
|
|
|
} else {
|
|
|
parser->push_warning(p_for->variable, GDScriptWarning::UNTYPED_DECLARATION, R"("for" iterator variable)", p_for->variable->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2336,7 +2336,7 @@ void GDScriptAnalyzer::resolve_for(GDScriptParser::ForNode *p_for) {
|
|
|
if (p_for->variable) {
|
|
|
is_shadowing(p_for->variable, R"("for" iterator variable)", true);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::resolve_while(GDScriptParser::WhileNode *p_while) {
|
|
@@ -2365,7 +2365,7 @@ void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {
|
|
|
parser->push_warning(p_assert->condition, GDScriptWarning::ASSERT_ALWAYS_FALSE);
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::resolve_match(GDScriptParser::MatchNode *p_match) {
|
|
@@ -2444,7 +2444,7 @@ void GDScriptAnalyzer::resolve_match_pattern(GDScriptParser::PatternNode *p_matc
|
|
|
if (p_match_pattern->bind->usages == 0 && !String(p_match_pattern->bind->name).begins_with("_")) {
|
|
|
parser->push_warning(p_match_pattern->bind, GDScriptWarning::UNUSED_VARIABLE, p_match_pattern->bind->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
break;
|
|
|
case GDScriptParser::PatternNode::PT_ARRAY:
|
|
|
for (int i = 0; i < p_match_pattern->array.size(); i++) {
|
|
@@ -2504,7 +2504,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
|
|
|
String called_function_name = static_cast<GDScriptParser::CallNode *>(p_return->return_value)->function_name.operator String();
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
parser->push_warning(p_return, GDScriptWarning::UNSAFE_VOID_RETURN, function_name, called_function_name);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
mark_node_unsafe(p_return);
|
|
|
} else if (!is_call) {
|
|
|
push_error("A void function cannot return a value.", p_return);
|
|
@@ -2547,7 +2547,7 @@ void GDScriptAnalyzer::resolve_return(GDScriptParser::ReturnNode *p_return) {
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
} else if (expected_type.builtin_type == Variant::INT && result.builtin_type == Variant::FLOAT) {
|
|
|
parser->push_warning(p_return, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2681,7 +2681,7 @@ static bool enum_has_value(const GDScriptParser::DataType p_type, int64_t p_valu
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::ExpressionNode *p_expression, const GDScriptParser::DataType &p_type, const char *p_usage, bool p_is_cast) {
|
|
|
if (p_expression->get_datatype() == p_type) {
|
|
@@ -2708,7 +2708,7 @@ void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::Expr
|
|
|
if (p_type.kind == GDScriptParser::DataType::ENUM && value_type.builtin_type == Variant::INT && !enum_has_value(p_type, p_expression->reduced_value)) {
|
|
|
parser->push_warning(p_expression, GDScriptWarning::INT_AS_ENUM_WITHOUT_MATCH, p_usage, p_expression->reduced_value.stringify(), p_type.to_string());
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (value_type.builtin_type == p_type.builtin_type) {
|
|
|
p_expression->set_datatype(p_type);
|
|
@@ -2728,7 +2728,7 @@ void GDScriptAnalyzer::update_const_expression_builtin_type(GDScriptParser::Expr
|
|
|
if (p_type.builtin_type == Variant::INT && value_type.builtin_type == Variant::FLOAT) {
|
|
|
parser->push_warning(p_expression, GDScriptWarning::NARROWING_CONVERSION);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
p_expression->reduced_value = converted_to;
|
|
|
p_expression->set_datatype(p_type);
|
|
@@ -2825,7 +2825,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|
|
id->variable_source->assignments++;
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
reduce_expression(p_assignment->assignee);
|
|
|
|
|
@@ -2865,7 +2865,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (p_assignment->assigned_value == nullptr || p_assignment->assignee == nullptr) {
|
|
|
return;
|
|
@@ -3014,7 +3014,7 @@ void GDScriptAnalyzer::reduce_assignment(GDScriptParser::AssignmentNode *p_assig
|
|
|
parser->push_warning(p_assignment, GDScriptWarning::UNASSIGNED_VARIABLE_OP_ASSIGN, id->name, Variant::get_operator_name(p_assignment->variant_op));
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
|
|
@@ -3048,7 +3048,7 @@ void GDScriptAnalyzer::reduce_await(GDScriptParser::AwaitNode *p_await) {
|
|
|
if (!to_await_type.is_coroutine && !to_await_type.is_variant() && to_await_type.builtin_type != Variant::SIGNAL) {
|
|
|
parser->push_warning(p_await, GDScriptWarning::REDUNDANT_AWAIT);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_op) {
|
|
@@ -3072,7 +3072,7 @@ void GDScriptAnalyzer::reduce_binary_op(GDScriptParser::BinaryOpNode *p_binary_o
|
|
|
if (p_binary_op->variant_op == Variant::OP_DIVIDE && left_type.builtin_type == Variant::INT && right_type.builtin_type == Variant::INT) {
|
|
|
parser->push_warning(p_binary_op, GDScriptWarning::INTEGER_DIVISION);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
if (p_binary_op->left_operand->is_constant && p_binary_op->right_operand->is_constant) {
|
|
|
p_binary_op->is_constant = true;
|
|
@@ -3313,7 +3313,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|
|
expected_types += "\", or \"" + types[types.size() - 1];
|
|
|
}
|
|
|
parser->push_warning(p_call->arguments[0], GDScriptWarning::UNSAFE_CALL_ARGUMENT, "1", "constructor", function_name, expected_types, "Variant");
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
p_call->set_datatype(call_type);
|
|
|
return;
|
|
|
}
|
|
@@ -3344,7 +3344,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|
|
if (par_type.builtin_type == Variant::INT && arg_type.builtin_type == Variant::FLOAT && builtin_type != Variant::INT) {
|
|
|
parser->push_warning(p_call, GDScriptWarning::NARROWING_CONVERSION, function_name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3362,7 +3362,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|
|
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "constructor", function_name, par_type.to_string(), arg_type.to_string_strict());
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
match = true;
|
|
|
call_type = type_from_property(info.return_val);
|
|
@@ -3400,7 +3400,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
p_call->set_datatype(call_type);
|
|
|
return;
|
|
@@ -3698,7 +3698,7 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a
|
|
|
} else if (!is_self && !(base_type.is_hard_type() && base_type.kind == GDScriptParser::DataType::BUILTIN)) {
|
|
|
parser->push_warning(p_call, GDScriptWarning::UNSAFE_METHOD_ACCESS, p_call->function_name, base_type.to_string());
|
|
|
mark_node_unsafe(p_call);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -3762,7 +3762,7 @@ void GDScriptAnalyzer::reduce_cast(GDScriptParser::CastNode *p_cast) {
|
|
|
mark_node_unsafe(p_cast);
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
parser->push_warning(p_cast, GDScriptWarning::UNSAFE_CAST, cast_type.to_string());
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
} else {
|
|
|
bool valid = false;
|
|
|
if (op_type.builtin_type == Variant::INT && cast_type.kind == GDScriptParser::DataType::ENUM) {
|
|
@@ -4387,7 +4387,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
|
|
|
if (p_identifier->variable_source && p_identifier->variable_source->assignments == 0 && !(p_identifier->get_datatype().is_hard_type() && p_identifier->get_datatype().kind == GDScriptParser::DataType::BUILTIN)) {
|
|
|
parser->push_warning(p_identifier, GDScriptWarning::UNASSIGNED_VARIABLE, p_identifier->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
break;
|
|
|
case GDScriptParser::IdentifierNode::LOCAL_ITERATOR:
|
|
|
p_identifier->set_datatype(p_identifier->bind_source->get_datatype());
|
|
@@ -4409,7 +4409,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident
|
|
|
if (!found_source && p_identifier->suite != nullptr && p_identifier->suite->has_local(p_identifier->name)) {
|
|
|
parser->push_warning(p_identifier, GDScriptWarning::CONFUSABLE_LOCAL_USAGE, p_identifier->name);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
// Not a local, so check members.
|
|
|
|
|
@@ -4831,7 +4831,7 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
|
|
|
if (valid) {
|
|
|
parser->push_warning(p_subscript, GDScriptWarning::UNSAFE_PROPERTY_ACCESS, p_subscript->attribute->name, base_type.to_string());
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
result_type.kind = GDScriptParser::DataType::VARIANT;
|
|
|
mark_node_unsafe(p_subscript);
|
|
|
}
|
|
@@ -5127,7 +5127,7 @@ void GDScriptAnalyzer::reduce_ternary_op(GDScriptParser::TernaryOpNode *p_ternar
|
|
|
result.kind = GDScriptParser::DataType::VARIANT;
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
parser->push_warning(p_ternary_op, GDScriptWarning::INCOMPATIBLE_TERNARY);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -5855,7 +5855,7 @@ bool GDScriptAnalyzer::get_function_signature(GDScriptParser::Node *p_source, bo
|
|
|
if (native_method && r_native_class) {
|
|
|
*r_native_class = native_method->get_instance_class();
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
return valid;
|
|
|
}
|
|
|
|
|
@@ -5911,7 +5911,7 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
|
|
|
mark_node_unsafe(p_call->arguments[i]);
|
|
|
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "function", p_call->function_name, par_type.to_string(), arg_type.to_string_strict());
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
} else if (par_type.is_hard_type() && !is_type_compatible(par_type, arg_type, true)) {
|
|
|
if (!is_type_compatible(arg_type, par_type)) {
|
|
|
push_error(vformat(R"*(Invalid argument for "%s()" function: argument %d should be "%s" but is "%s".)*",
|
|
@@ -5922,12 +5922,12 @@ void GDScriptAnalyzer::validate_call_arg(const List<GDScriptParser::DataType> &p
|
|
|
// Supertypes are acceptable for dynamic compliance, but it's unsafe.
|
|
|
mark_node_unsafe(p_call);
|
|
|
parser->push_warning(p_call->arguments[i], GDScriptWarning::UNSAFE_CALL_ARGUMENT, itos(i + 1), "function", p_call->function_name, par_type.to_string(), arg_type.to_string_strict());
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
} else if (par_type.kind == GDScriptParser::DataType::BUILTIN && par_type.builtin_type == Variant::INT && arg_type.kind == GDScriptParser::DataType::BUILTIN && arg_type.builtin_type == Variant::FLOAT) {
|
|
|
parser->push_warning(p_call->arguments[i], GDScriptWarning::NARROWING_CONVERSION, p_call->function_name);
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -6088,7 +6088,7 @@ bool GDScriptAnalyzer::is_type_compatible(const GDScriptParser::DataType &p_targ
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
return check_type_compatibility(p_target, p_source, p_allow_implicit_conversion, p_source_node);
|
|
|
}
|
|
|
|
|
@@ -6260,7 +6260,7 @@ void GDScriptAnalyzer::mark_node_unsafe(const GDScriptParser::Node *p_node) {
|
|
|
for (int i = p_node->start_line; i <= p_node->end_line; i++) {
|
|
|
parser->unsafe_lines.insert(i);
|
|
|
}
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
}
|
|
|
|
|
|
void GDScriptAnalyzer::downgrade_node_type_source(GDScriptParser::Node *p_node) {
|
|
@@ -6376,7 +6376,7 @@ Error GDScriptAnalyzer::resolve_body() {
|
|
|
#ifdef DEBUG_ENABLED
|
|
|
// Apply here, after all `@warning_ignore`s have been resolved and applied.
|
|
|
parser->apply_pending_warnings();
|
|
|
-#endif
|
|
|
+#endif // DEBUG_ENABLED
|
|
|
|
|
|
return parser->errors.is_empty() ? OK : ERR_PARSE_ERROR;
|
|
|
}
|