bugGNU Octave - Bugs: bug #38758, Parser oddity with 'if' statements...


bug #38758: Parser oddity with 'if' statements and spurious display with nargin

Submitted by:  Guillaume <gyom>
Submitted on:  Wed 17 Apr 2013 11:25:53 AM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  John W. Eaton <jwe>
Originator Name:  Guillaume Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment (Rich Markup)

You are not logged in

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


Thu 20 Jun 2013 02:13:10 AM UTC, comment #3: 
John W. Eaton <jwe>
Project AdministratorIn charge of this item.
Wed 19 Jun 2013 10:46:18 PM UTC, comment #2: 

I think the problem is also related to the path the parser is taking through if statements.  For example, using a pair of parentheses around the condition of the if statement also fixes the problem.

if (nargin >=3), disp('test'); end

Ordinarily code of the form


is equivalent to


as the comma just tells the parser that a new statement has begun.  This seems to be the case here for whatever reason.

if nargin >=3, disp('test'); end
seems to be parsed as
">=3", disp('test');
ans = >=3

In fact, I would guess that the problem is that the if conditional is not being greedy enough and stops after accepting nargin.  Thus, the parsing results in

if nargin

Rik <rik5>
Project Administrator
Sat 11 May 2013 10:06:44 AM UTC, comment #1: 


Clemens Buchacher <drizzd>
Wed 17 Apr 2013 11:25:53 AM UTC, original submission:  

Since recent changes in the Octave parser, I observe spurious displays due to lines such as:

if nargin >=3, disp('test'); end

it displays:

ans = >=3

It doesn't happen with different call syntax:

if nargin>=3, disp('test'); end
if nargin >= 3, disp('test'); end
if nargin() >=3, disp('test'); end

Guillaume <gyom>


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

Attach Files:

No files currently attached


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 rik5
  • -email is unavailable- added by jordigh (Updated the item)
  • -email is unavailable- added by drizzd (Posted a comment)
  • -email is unavailable- added by gyom (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-06-20 jwe StatusConfirmed => Fixed
        Open/ClosedOpen => Closed
    2013-06-19 jwe Assigned toNone => jwe
    2013-06-19 rik5 SummarySpurious display with nargin => Parser oddity with 'if' statements and spurious display with nargin
        Carbon-Copy- => Added jwe
    2013-05-11 jordigh StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.5