Mercurial > octave
changeset 32260:5d9311556111
VM set error id and fn name in error message at invalid function call
* pt-bytecode-vm-internal.h: Set error fields
* pt-bytecode-vm.cc: Set error fields
author | Petter T. |
---|---|
date | Wed, 09 Aug 2023 12:56:03 +0200 |
parents | 2f93bc7f3cf7 |
children | 6d2f6ca0996f |
files | libinterp/parse-tree/pt-bytecode-vm-internal.h libinterp/parse-tree/pt-bytecode-vm.cc |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/pt-bytecode-vm-internal.h Tue Aug 08 16:00:56 2023 +0200 +++ b/libinterp/parse-tree/pt-bytecode-vm-internal.h Wed Aug 09 12:56:03 2023 +0200 @@ -399,7 +399,8 @@ \ if (n_args_on_callee_stack > n_args_callee) \ { \ - (*sp++).pee = new execution_exception {"error","","function called with too many inputs"}; \ + std::string fn_name = unwind_data->m_name; \ + (*sp++).pee = new execution_exception {"error", "Octave:invalid-fun-call", fn_name + ": function called with too many inputs"};\ (*sp++).i = static_cast<int> (error_type::EXECUTION_EXC); \ goto unwind; \ } \ @@ -407,7 +408,8 @@ int n_returns = N_RETURNS () - 1; /* %nargout in N_RETURNS */ \ if (n_returns >= 0 && nargout > n_returns) \ { \ - (*sp++).pee = new execution_exception {"error","","function called with too many outputs"}; \ + std::string fn_name = unwind_data->m_name; \ + (*sp++).pee = new execution_exception {"error", "Octave:invalid-fun-call", fn_name + ": function called with too many outputs"};\ (*sp++).i = static_cast<int> (error_type::EXECUTION_EXC); \ goto unwind; \ } \
--- a/libinterp/parse-tree/pt-bytecode-vm.cc Tue Aug 08 16:00:56 2023 +0200 +++ b/libinterp/parse-tree/pt-bytecode-vm.cc Wed Aug 09 12:56:03 2023 +0200 @@ -958,14 +958,18 @@ /* We do the number of args check after frame init so that the unwind is easier. */ if (!is_varargin && n_args < n_root_args) { - (*sp++).pee = new execution_exception {"error","","function called with too many inputs"}; + std::string fn_name = unwind_data->m_name; + (*sp++).pee = new execution_exception {"error", "Octave:invalid-fun-call", + fn_name + ": function called with too many inputs"}; (*sp++).i = static_cast<int> (error_type::EXECUTION_EXC); ip++; // unwind expects ip to point to two after the opcode being executed goto unwind; } if (!is_varargout && root_nargout > n_returns - 1) // n_returns includes %nargout, so subtract one { - (*sp++).pee = new execution_exception {"error","","function called with too many outputs"}; + std::string fn_name = unwind_data->m_name; + (*sp++).pee = new execution_exception {"error", "Octave:invalid-fun-call", + fn_name + ": function called with too many outputs"}; (*sp++).i = static_cast<int> (error_type::EXECUTION_EXC); ip++; goto unwind;