Lsqnonlin from optim package doesn't work under Octave 7.0.90

This minimal example works under Octave 6.4.0 but throws an error in Octave 7.0.90 (plus, there are a couple of warnings when loading the optim package):

pkg load optim

x = (0:0.01:10).';
y = @(p) p(1) + p(2)*sin(2*pi*p(3)*x);

p0 = [0.3 0.5 0.2];
y0 = y([0.37 0.63 0.21]) + (rand(size(x))-0.5);

p_fit = lsqnonlin(@(p) y(p) - y0,p0);

I get this error:

error: : function called with too many inputs
error: called from
    __dfdp__ at line 304 column 15
    __nonlin_residmin__>@<anonymous> at line 329 column 26
    __jacobian_constants__>@<anonymous> at line 121 column 11
    __lm_svd__ at line 196 column 9
    __nonlin_residmin__ at line 452 column 25
    nonlin_residmin at line 98 column 25
    lsqnonlin at line 264 column 21
    optim_bug at line 9 column 7

It seems to boil down to line 316 in __nonlin_residmin__

f.f = @ (varargin) f.f (varargin{:}) - obs;

which doesn’t seem to be allowed anymore.

My system

That’s probably an undesired side effect of the interpreter checking the maximum number of input arguments. It looks like that check fails for anonymous functions with varargin.

Could you please open a bug report on Savannah:
GNU Octave - Bugs: Submit Item [Savannah]

Done: GNU Octave - Bugs: bug #61801, lsqnonlin from optim package... [Savannah]