bugGNU Octave - Bugs: bug #45969, Inner scopes of nested anonymous...


bug #45969: Inner scopes of nested anonymous function definitions are not saved.

Submitted by:  Olaf Till <i7tiol>
Submitted on:  Tue 15 Sep 2015 08:51:13 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Olaf Till Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

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


Tue 28 Aug 2018 12:23:26 AM UTC, comment #4:

I applied your changeset and didn't see any failures from 'make check'. I pushed it to the development branch here (https://hg.savannah.gnu.org/hgweb/octave/rev/91e1ca0e3a9d). Marking as fixed and closing report.

Rik <rik5>
Project Administrator
Sat 18 Aug 2018 09:35:49 PM UTC, comment #3:

A refreshed changeset ('bug-45969-version2.cset') is attached. Octave internals have changed since the first version, so there was more to do than adapting to C++11-isms...

In octave_fcn_handle::save_ascii, ::save_binary, ::save_hdf5 I decided to throw an error if the scope isn't valid, since AFAICS this is not supposed to happen. Also, except in ::save_hdf5 (because it was too complex), I re-ordered the code a bit so that no data is written until after the error checks, to avoid writing incomplete data.

BTW, already in the previous code state, in case of errors in the ::save_... functions, sometimes 'false' is returned and sometimes an error is thrown... and the returned 'false' seems never to be checked at all when saving to files. This is probably not ideal. As long as the returned 'false' is not checked, it's probably better to throw errors...

Two of the constructors of tree_anon_scopes are currently not used. If suitable, they can be used for something like

The test file has been changed according to the way you (Rik) changed the tests for bug #45972.

(file #44808)

Olaf Till <i7tiol>
Project Member
Wed 15 Aug 2018 08:31:58 PM UTC, comment #2:

Thanks for looking at this, I'll try to refresh the patch at the weekend...

Olaf Till <i7tiol>
Project Member
Wed 15 Aug 2018 05:50:54 PM UTC, comment #1:

I started to take a look at this but the patch supplied no longer applies cleanly to the development tree.

@Olaf: Could you refresh the patch? It seems like the base code has changed to use more C++11 features like for() over a collection which might need to be copied in to pt-anon-scopes.cc.

Rik <rik5>
Project Administrator
Tue 15 Sep 2015 08:51:13 AM UTC, original submission:

Anonymous functions handles contain an own scope with the variables they inherited from the parent scope. If anonymous function handles are saved (ascii, binary, or hdf5), the variables of this scope are also saved. But currently, if anonymous function definitions are nested (e.g.
), the variables in the scopes of the 'inner' anonymous functions (variable 'a' in
in the example) are not saved.

Simple example for triggering this bug:

More realistic example for triggering this bug:

The fix (single changeset to be attached as soon as I know the bug number) firstly provides a new class, derived from class tree_walker, to collect the variables of all scopes of potentially nested anonymous function handles, secondly lets the
methods use this class for saving anonymous functions, and thirdly provides a test (with the second example above).

Olaf Till <i7tiol>
Project Member


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

Attach Files:

Attached Files
file #44808:  bug-45969-version2.cset added by i7tiol (21KiB - application/octet-stream)
file #34887:  bug-45969.cset added by i7tiol (19KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by i7tiol (Submitted the item)

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

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-28 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2018-08-18 i7tiol Attached File- => Added bug-45969-version2.cset, #44808
    2015-10-08 mtmiller StatusNone => Patch Submitted
    2015-09-15 i7tiol Attached File- => Added bug-45969.cset, #34887

    Back to the top

    Powered by Savane 3.3