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

 
 

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

Submitter:  Guillaume <gyom>
Submitted:  Wed 17 Apr 2013 11:25:53 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Other
Status:  Fixed Assigned to:  jwe
Originator Name:  Guillaume Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 20 Jun 2013 02:13:10 AM UTC, comment #3: 
John W. Eaton <jwe>
Group administrator
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

STATEMENT1, STATEMENT2

is equivalent to

STATEMENT1
STATEMENT2

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
test


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
   ">=3",
   "disp('test');
end


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

Confirmed.

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
test


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:
   
   
Comment:
   

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)
  •  

    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 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.13-4448.
    Corresponding source code