more information added to error message in macro call 18/17118/5
Cedric Delamarre [Thu, 27 Aug 2015 09:05:46 +0000 (11:05 +0200)]
function [a,b,c]=foo()
  a=1
  // b=1
  c=1
endfunction

[x,y,z]=foo()

Change-Id: I7fcafa94be3fc59929d2ebcee999ef97eb0ef296

scilab/modules/ast/src/cpp/types/macro.cpp

index 9e580f4..6ae1cc7 100644 (file)
@@ -110,7 +110,6 @@ bool Macro::toString(std::wostringstream& ostr)
     // get macro name
     wchar_t* wcsVarName = os_wcsdup(ostr.str().c_str());
     ostr.str(L"");
-
     ostr << L"[";
 
     // output arguments [a,b,c] = ....
@@ -386,9 +385,11 @@ Callable::ReturnValue Macro::call(typed_list &in, optional_list &opt, int _iRetC
                 out.clear();
                 cleanCall(pContext, oldVal);
 
-                char* pst = wide_string_to_UTF8((*i)->getSymbol().getName().c_str());
-                Scierror(999, _("Undefined variable %s.\n"), pst);
-                FREE(pst);
+                char* pstArgName = wide_string_to_UTF8((*i)->getSymbol().getName().c_str());
+                char* pstMacroName = wide_string_to_UTF8(getName().c_str());
+                Scierror(999, _("Undefined variable '%s' in function '%s'.\n"), pstArgName, pstMacroName);
+                FREE(pstArgName);
+                FREE(pstMacroName);
                 return Callable::Error;
             }
         }