bugGNU Octave - Bugs: bug #45972, Anonymous function handles with...


bug #45972: Anonymous function handles with varargin are not correctly saved.

Submitted by:  Olaf Till <i7tiol>
Submitted on:  Tue 15 Sep 2015 08:38:12 PM UTC  
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: Patch SubmittedAssigned to: None
Originator Name: Olaf TillOpen/Closed: Open
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 04 Jul 2016 01:42:08 PM UTC, comment #4:

This patch still applies.

The test fails if the user has set the default file save format to something other than "text". The attached patch fixes that.

(file #37704)

Lachlan Andrew <lachlan>
Project Member
Wed 16 Sep 2015 02:09:49 PM UTC, comment #3:

Attached such a changeset, containing also a test. Couldn't test the also changed
since it is nowhere used in Octaves code, but I think the change is ok.

(file #34902)

Olaf Till <i7tiol>
Project Member
Wed 16 Sep 2015 01:47:36 PM UTC, comment #2:

No, varargin is indeed no extra parse tree element, tree_parameter_list has an entry indicating if varargs are taken.

I've seen now that visit_octave_user_function_header calls (indirectly) visit_parameter_list and afterwards prints 'varargin', if necessary.

OTOH, visit_anon_fcn_handle only calls (indirectly) visit_parameter_list and does not care for varargin.

As I see it now, visit_anon_fcn_handle shouldn't be changed (it can't be called from
anyway, since octave_fcn_handle is contained in tree_anon_fcn_handle), but visit_octave_user_function should be changed so that it not cares itself for varargin, but varargin should be cared for by visit_parameter_list.

Olaf Till <i7tiol>
Project Member
Wed 16 Sep 2015 12:14:02 PM UTC, comment #1:

varargin isn't a parse tree element by itself, is it? If not, then there shouldn't be a separate visit_varargin method in the tree_walker class.

I'm a bit surprised that visit_parameter_list doesn't handle varargin. I haven't looked at the code yet, but I think that's probably the place where this should be fixed.

John W. Eaton <jwe>
Project Administrator
Tue 15 Sep 2015 08:38:12 PM UTC, original submission:

Anonymous function handles using varargin are not correctly saved and thus can't be reloaded. Example:

It's the same for saving in binary or hdf5 format. The reason is that the function definition is saved with
, which doesn't print the 'varargin' (as you also see above).

I'd like to make a changeset for fixing
, it's not difficult, but there are two possibilities:

1. adding printing of 'varargin' directly in
after printing the parameter list,


2. handling printing of 'varargin' within the printing of the parameter list, i.e. in

I'd vote for 2., but I'll ask at the maintainers list before submitting a changeset.

Olaf Till <i7tiol>
Project Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #34902:  bug-45972.cset added by i7tiol (3KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by lachlan (Updated the item)
  • -unavailable- added by mtmiller (Updated the item)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by i7tiol (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 04 Jul 2016 01:42:08 PM UTClachlanAttached File-=>Added bug_45972_anon_varargin.cset, #37704
    Thu 08 Oct 2015 11:27:26 AM UTCmtmillerStatusNone=>Patch Submitted
    Wed 16 Sep 2015 02:09:49 PM UTCi7tiolAttached File-=>Added bug-45972.cset, #34902

    Back to the top

    Powered by Savane 3.1-cleanup1