bugGNU Octave - Bugs: bug #48031, command syntax fails when a local...

 
 

bug #48031: command syntax fails when a local variable in another scope shadows command

Submitter:  Mike Miller <mtmiller>
Submitted:  Thu 26 May 2016 05:06:59 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
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
   

Thu 02 Jun 2016 10:03:25 PM UTC, comment #5: 
John W. Eaton <jwe>
Group administrator
Sat 28 May 2016 11:49:49 AM UTC, comment #4: 

Try the attached patch.  I think this could be checked in now, but I'm thinking that some of the other functions in the symbol table class could use the same change so that they could be used for any scope, not just the current one.


(file #37296)

John W. Eaton <jwe>
Group administrator
Sat 28 May 2016 01:07:00 AM UTC, comment #3: 

Really weird stuff here.

I modified foo.m to


function foo ()
  exist axis
endfunction


And then


foo
clear -f
exist = 1;
foo
parse error near line 2 of file /home/rik/wip/Projects_Mine/octave-dev/foo.m

  syntax error

>>>   exist axis
exit
error: exist(115,_): but exist has size 1x1
error: ignoring const octave_execution_exception& while preparing to exit



Rik <rik5>
Group administrator
Fri 27 May 2016 10:36:36 PM UTC, comment #2: 

Confirmed.  This is a bug of longstanding.  It appeared somewhere between version 3.6.4 and 3.8.2.

Also confirmed, switching from command syntax to function syntax makes this work.


Rik <rik5>
Group administrator
Thu 26 May 2016 05:22:34 PM UTC, comment #1: 

Ok, an even simpler example:


type foo.m
function foo ()
  axis tight
endfunction

foo  ## no error here
axis = [];
foo  ## no error here because the function was already parsed
clear -f
foo  ## parse error on axis command


Mike Miller <mtmiller>
Group Member
Thu 26 May 2016 05:06:59 PM UTC, original submission:  

This was reported on irc with the MIRToolbox (https://www.jyu.fi/hum/laitokset/musiikki/en/research/coe/materials/mirtoolbox/Download).

The following minimal reproducer throws the error for me:


#### myplot.m ####

function myplot (ax)
  if (isempty (ax))
    figure ();
  endif

  plot (1:10);
  hold on
  axis tight
endfunction

#### @myclass/myclass.m ####

function y = myclass ()
  y = class (struct (), "myclass");
endfunction

#### @myclass/plot.m ####

function plot (x)
  axis = [];
  myplot (axis);
endfunction


The error is the same as if "axis" were a variable in the current scope, it appears as a "parser error" on the function that is called with command syntax.


parse error near line 8 of file /path/to/myplot.m

  syntax error

>>>   axis tight
                ^

error: called from
    plot at line 3 column 3


Mike Miller <mtmiller>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #37296:  diffs.txt added by jwe (2KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by mtmiller (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
    2016-06-02 jwe StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-05-28 jwe Attached File- Added diffs.txt, #37296
    2016-05-27 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code