diff --git a/src/parser/preprocessor/default.cpp b/src/parser/preprocessor/default.cpp index c100475c..7a9dbf85 100644 --- a/src/parser/preprocessor/default.cpp +++ b/src/parser/preprocessor/default.cpp @@ -410,7 +410,7 @@ std::string sqf::parser::preprocessor::impl_default::instance::replace( const std::vector ¯o_stack) { if (m.args().size() != params.size()) { m_errflag = true; - log(err::ArgCountMissmatch(m.diag_info())); + log(err::ArgCountMissmatch(original_fileinfo.to_diag_info(), m.diag_info(), m.args().size(), params.size(), std::string(m.name().begin(), m.name().end()))); return ""; } context local_fileinfo(m.diag_info()); diff --git a/src/runtime/logging.cpp b/src/runtime/logging.cpp index 40768c79..94ce1432 100644 --- a/src/runtime/logging.cpp +++ b/src/runtime/logging.cpp @@ -72,10 +72,40 @@ namespace logmessage::preprocessor { std::string ArgCountMissmatch::formatMessage() const { auto output = m_location.format(); - auto const message = "Arg Count Missmatch."sv; - - output.reserve(output.length() + message.length()); - output.append(message); + auto macro_line = std::to_string(m_macro_location.line); + auto macro_column = std::to_string(m_macro_location.col); + auto macro_path = m_macro_location.path; + auto expected_arg_count = std::to_string(m_expected_arg_count); + auto actual_arg_count = std::to_string(m_actual_arg_count); + output.reserve( + output.length() + + "The macro '"sv.length() + + m_macro_name.length() + + "' at line '"sv.length() + + macro_line.length() + + "' column '"sv.length() + + macro_column.length() + + "' in file '"sv.length() + + macro_path.length() + + "' expects '"sv.length() + + expected_arg_count.length() + + "' arguments but got '"sv.length() + + actual_arg_count.length() + + "'."sv.length() + ); + output.append("The macro '"sv); + output.append(m_macro_name); + output.append("' at line '"sv); + output.append(macro_line); + output.append("' column '"sv); + output.append(macro_column); + output.append("' in file '"sv); + output.append(macro_path); + output.append("' expects '"sv); + output.append(expected_arg_count); + output.append("' arguments but got '"sv); + output.append(actual_arg_count); + output.append("'."sv); return output; } diff --git a/src/runtime/logging.h b/src/runtime/logging.h index 4562cc9e..72c654cc 100644 --- a/src/runtime/logging.h +++ b/src/runtime/logging.h @@ -124,8 +124,22 @@ namespace logmessage { class ArgCountMissmatch : public PreprocBase { static const loglevel level = loglevel::error; static const size_t errorCode = 10001; - public: - ArgCountMissmatch(LogLocationInfo loc) : PreprocBase(level, errorCode, std::move(loc)) {} + LogLocationInfo m_macro_location; + size_t m_expected_arg_count; + size_t m_actual_arg_count; + std::string m_macro_name; + public: + ArgCountMissmatch( + LogLocationInfo loc, + LogLocationInfo macro_location, + size_t expected_arg_count, + size_t actual_arg_count, + std::string macro_name) : + PreprocBase(level, errorCode, std::move(loc)), + m_macro_location(macro_location), + m_expected_arg_count(expected_arg_count), + m_actual_arg_count(actual_arg_count), + m_macro_name(std::move(macro_name)) {} [[nodiscard]] std::string formatMessage() const override; };