Affecting a function with a list parameter cannot be called
Reported by Laurent Cetinsoy
BUG DESCRIPTION:
----------------
Putting a function, with a list as unique paramete, in a struct, changes its behavior. The list seems to be converted into a parameter sequence (which is also a list if I am not mistaking) and generating an error.
ERROR LOG:
----------
!--error 58
Wrong number of input arguments.at line of function BugShowcase called by :
BugShowcase()
at line of exec file called by :
HOW TO REPRODUCE THE BUG:
-------------------------
function BugShowcase()
disp('example 1')
function res = SumAList(myList)
disp("number of SumAList parameters: " + string(argn(2)))
res = myList(1) + myList(2);
endfunction
Namespace.SumAList = SumAList;
a = list(1, 1);
disp('Function alone works')
disp('result is: ' + string(SumAList(a)))
disp('Function in the struct does not');
try
disp(Namespace.SumAList(a))
catch
disp("error:" + lasterror());
end
disp('example 2')
//I put optional to show that it considers that there are as many arguments as items in the list parameters
function res = SumAList2(myList, optional)
//now it enters the function because nParam = length(List)
disp("number of SumAList parameters: " + string(argn(2)))
res = myList(1) + myList(2);
endfunction
Namespace.SumAList2 = SumAList2;
a = list(1, 1);
disp('Works');
disp('result is: ' + string(SumAList2(a)))
disp('Does not work');
disp(Namespace.SumAList2(a))
endfunction
BugShowcase()
OTHER INFORMATION:
------------------