diff --git a/Core/GDCore/IDE/Events/ExpressionValidator.cpp b/Core/GDCore/IDE/Events/ExpressionValidator.cpp index b370fc4e133e..228a6589dbdf 100644 --- a/Core/GDCore/IDE/Events/ExpressionValidator.cpp +++ b/Core/GDCore/IDE/Events/ExpressionValidator.cpp @@ -298,13 +298,11 @@ ExpressionValidator::Type ExpressionValidator::ValidateFunction( // Check if the expression is deprecated if (metadata.IsDeprecated()) { gd::String deprecationMessage = metadata.GetDeprecationMessage(); - auto diagnostic = gd::make_unique( + RaiseWarning( gd::ExpressionParserError::ErrorType::DeprecatedExpression, _("This expression is deprecated.") + (deprecationMessage.empty() ? "" : " " + deprecationMessage), function.location); - deprecationWarnings.push_back(diagnostic.get()); - supplementalErrors.push_back(std::move(diagnostic)); } // Validate the type of the function diff --git a/Core/GDCore/IDE/Events/ExpressionValidator.h b/Core/GDCore/IDE/Events/ExpressionValidator.h index 366be17a36be..ca60a73cbe51 100644 --- a/Core/GDCore/IDE/Events/ExpressionValidator.h +++ b/Core/GDCore/IDE/Events/ExpressionValidator.h @@ -488,6 +488,20 @@ class GD_CORE_API ExpressionValidator : public ExpressionParser2NodeWorker { supplementalErrors.push_back(std::move(diagnostic)); } + void RaiseWarning(gd::ExpressionParserError::ErrorType type, + const gd::String &message, + const ExpressionParserLocation &location, + const gd::String &actualValue = "", + const gd::String &objectName = "") { + auto diagnostic = gd::make_unique( + type, message, location, actualValue, objectName); + deprecationWarnings.push_back(diagnostic.get()); + // Warnings found by the validator are not holden by the AST nodes. + // They must be owned by the validator to keep living while warnings are + // handled by the caller. + supplementalErrors.push_back(std::move(diagnostic)); + } + void RaiseUnknownIdentifierError(const gd::String &message, const ExpressionParserLocation &location) { RaiseError(gd::ExpressionParserError::ErrorType::UnknownIdentifier, message,