bugGNU Octave - Bugs: bug #31793, case statement required for...

 
 

bug #31793: case statement required for otherwise to be used in a switch

Submitted by:  jkirby <jkirby>
Submitted on:  Sun 05 Dec 2010 07:11:32 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Other
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: 3.3.53Operating System: Other

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Wed 08 Dec 2010 06:21:37 AM UTC, comment #6:

OK, I checked in this change too:

http://hg.savannah.gnu.org/hgweb/octave/rev/baeeb6bc6afe

John W. Eaton <jwe>
Project Administrator
Wed 08 Dec 2010 04:41:28 AM UTC, comment #5:

One final test case along the lines of the last one. If I run tst_switch with the case/otherwise in the correct order it works. Now, with Octave still open, modify the file tst_switch.m in an external editor and put the otherwise block before the case block. Finally, try re-running tst_switch. Octave correctly detects that the script has changed and re-parses it, but now I get 3 parse errors on the same line. After the first calling instance Octave quiets down again and subsequent calls to tst_switch produce only 1 parse error.

Sequence:

(file #22157)

Rik <rik5>
Project Administrator
Tue 07 Dec 2010 08:32:49 PM UTC, comment #4:

I checked in the following additional change:

http://hg.savannah.gnu.org/hgweb/octave/rev/f8e97e9a9301

John W. Eaton <jwe>
Project Administrator
Tue 07 Dec 2010 07:03:37 PM UTC, comment #3:

The patch works. However, I have a slightly different question. If I reverse the order of otherwise and the first case statement I get 2 parse errors in a row. I know this is disallowed, but shouldn't it produce just one parse error? It's obviously not critical but if it were easy to fix that would be nice as well. Interestingly, if I use 'source tst_switch.m' , rather than calling the file with 'tst_switch', I get only one parse error. I've attached the trivial script in question.

Test Sequence

(file #22146)

Rik <rik5>
Project Administrator
Tue 07 Dec 2010 06:00:54 PM UTC, comment #2:

I checked in the following change:

http://hg.savannah.gnu.org/hgweb/octave/rev/2da532d0f41c

John W. Eaton <jwe>
Project Administrator
Mon 06 Dec 2010 12:53:33 AM UTC, comment #1:

Confirmed on a recent tip (11313:988d2bd6bacd).

Rik <rik5>
Project Administrator
Sun 05 Dec 2010 07:11:32 PM UTC, original submission:

As the title says, Octave does not allow statements of the form:

switch index
otherwise
default_something = []
end

unless I put a case statement before the otherwise.

Sorry if it's a bit pendantic but this is something that has been recurring in my users code-base and MATLAB does allow it.

jkirby <jkirby>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #22157:  tst_switch2.m added by rik5 (71B - application/octet-stream)
file #22146:  tst_switch.m added by rik5 (71B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jkirby (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 08 Dec 2010 04:41:28 AM UTCrik5Attached File-=>Added tst_switch2.m, #22157
    Tue 07 Dec 2010 07:03:37 PM UTCrik5Attached File-=>Added tst_switch.m, #22146
    Tue 07 Dec 2010 06:00:54 PM UTCjweStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 06 Dec 2010 12:53:33 AM UTCrik5Item GroupNone=>Other
      StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1