bugGNU Octave - Bugs: bug #36217, New variables should be disallowed...

 
 

bug #36217: New variables should be disallowed in nested functions

Submitter:  Max Brister <fisheater>
Submitted:  Mon 16 Apr 2012 09:58:16 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 25 Aug 2012 11:04:33 PM UTC, comment #2: 
Max Brister <fisheater>
Wed 18 Apr 2012 03:53:24 AM UTC, comment #1: 

I now have a patch. It was not quite as simple to fix as I had hoped (is it ever?). Anyways, the idea is
- Mark a symbol_tables as static_workspaces once parsing is complete
- If a symbol is added to a static_workspace, mark it as added_static
- Call symbol_table::force_varref to get around marking symbols with added_static (used for .varargin., ans, ect.)
- If a symbol marked as added_static is accessed as a variable by tree_indentifier::rvalue or tree_indentifier::lvalue error

This silliness exists because can't disallow adding new symbol_records to static workspaces because that would prevent users from calling new functions.

I have checked, and I see no new errors with this patch applied ontop of 14570:d07d96e53612.

(file #25674)

Max Brister <fisheater>
Mon 16 Apr 2012 09:58:16 PM UTC, original submission:  

Code like

function foo
  eval ('x = 5;');
  bar ();

  function bar
    # Which x should this be?
    disp (x);
  endfunction
endfunction

foo ();


This should error as it causes problems for variable scopes. This is consistent with how matlab handles the issue. I am currently working on a patch.

Max Brister <fisheater>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #25674:  static_workspace.patch added by fisheater (11KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by fisheater (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-25 fisheater StatusNone Fixed
        Open/ClosedOpen Closed
    2012-04-18 fisheater Attached File- Added static_workspace.patch, #25674

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code