From bug-octave-request at bevo dot che dot wisc dot edu Fri Jan 15 17:16:33 1999 Subject: [50 character or so descriptive subject here (for reference)] From: "John W. Eaton" To: A Scott Hodel Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 15 Jan 1999 17:16:30 -0600 (CST) On 15-Jan-1999, A Scott Hodel wrote: | Bug report for Octave 2.1.10 configured for %CANONICAL_HOST_TYPE% | | Description: | ----------- | | Problem in parsing m-file with unclosed for loop inside a switch: | edalf:/S4/hodel/oct $ octave | Octave, version 2.1.10 (alphaev56-dec-osf4.0b). | Copyright (C) 1996, 1997, 1998 John W. Eaton. | This is free software with ABSOLUTELY NO WARRANTY. | For details, type `warranty'. | | octave:1> errtest.m | parse error near line 7 of file /S4/hodel/oct/errtest.m | | >>> endswitch | ^ | | panic: impossible state reached in file `parse.y' at line 1435 | error: IOT/Abort trap -- stopping myself... | attempting to save variables to `octave-core'... | save to `octave-core' complete | Resources lost(coredump) | | Repeat-By: | --------- | File errtest.m: | for ii=1:3 | switch(ii) | case(1), | printf("Hello "); | for kk=1:4 | kk | endswitch | endfor | | Fix: | --- | | unknown; correct behavior is to report for loop closed by endswitch | and return to octave prompt. [Since I'm working with 2.1.10, | this may be repaired in later versions.] Unfortunately, no. This looks like a classic example of why switch is bad and objects with virtual functions are good. I should probably at least rewrite the end_error function as a member function in the token class... Until then though, here is a fix. Thanks, jwe Fri Jan 15 13:04:58 1999 John W. Eaton * parse.y (end_error): Handle case of endswitch too. Index: parse.y =================================================================== RCS file: /home/jwe/src/master/octave/src/parse.y,v retrieving revision 1.138 diff -c -r1.138 parse.y *** parse.y 1998/11/11 20:47:10 1.138 --- parse.y 1999/01/15 23:12:21 *************** *** 1423,1428 **** --- 1423,1432 ---- error (fmt, type, "endif", l, c); break; + case token::switch_end: + error (fmt, type, "endswitch", l, c); + break; + case token::while_end: error (fmt, type, "endwhile", l, c); break;