bugGNU Octave - Bugs: bug #53405, eval cannot create variables...

 
 

bug #53405: eval cannot create variables inside "local functions"

Submitter:  Kai Torben Ohlhus <siko1056>
Submitted:  Wed 21 Mar 2018 03:33:35 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  siko1056
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 21 Mar 2018 09:04:01 PM UTC, comment #2: 

Thanks for reviewing my patch.

I adapted the BIST to your suggestion (you are right, this is all that matter about this item) and pushed it:  https://hg.savannah.gnu.org/hgweb/octave/rev/1fbd8afcf625

Kai Torben Ohlhus <siko1056>
Group Member
Wed 21 Mar 2018 04:06:13 PM UTC, comment #1: 

You change seems fine to me.

Another way to test would be


function status = local_function_eval ()
  eval ("y = 5;");  # works
  status = local_fcn ("y = 6");
endfunction

function status = local_fcn (expr)
  eval (expr);  # No longer works since 4.3.0+
  status = exist ("y");
endfunction


John W. Eaton <jwe>
Group administrator
Wed 21 Mar 2018 03:33:35 PM UTC, original submission:  

With the fix of bug #51698 the creation of variables inside "local functions" (sometimes called "subfunction" not to be confused with "nested functions" [1]) is no longer possible due to a static workspace marking.

Assume the following function file "local_function_eval.m":


function x = local_function_eval ()
  eval ("y = 5; x = y;");  # works
  x = local_fcn ("y = 6; x = y;");
endfunction

function x = local_fcn (expr)
  eval (expr);  # No longer works since 4.3.0+
endfunction


In Octave 4.2.2 and before this was allowed as in Matlab R2017b and before.

There are some ways to get around this, but I find it a legitimate usage (in contrast to "nested functions", see bug #51698).

The changeset was http://hg.savannah.gnu.org/hgweb/octave/rev/4b0e0cae49db but nowadays some files have changed (for example symscope.cc).

Is there a way to better distinguish between local and nested functions in symscope.cc than in my attached patch?

[1] https://octave.org/doc/interpreter/Nested-Functions.html

Kai Torben Ohlhus <siko1056>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #43617:  bug24942.patch added by siko1056 (4KiB - text/x-patch)

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by siko1056 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-03-21 siko1056 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2018-03-21 siko1056 Dependencies- Depends on bugs #51698
    2018-03-21 siko1056 Attached File- Added bug24942.patch, #43617

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code