Ticket UUID: | 2383005 | |||
Title: | return -errorcode accepts non-list argument | |||
Type: | Bug | Version: | obsolete: 8.5.5 | |
Submitter: | dgp | Created on: | 2008-12-03 15:00:39 | |
Subsystem: | 45. Parsing and Eval | Assigned To: | dgp | |
Priority: | 9 Immediate | Severity: | ||
Status: | Closed | Last Modified: | 2010-03-24 22:29:28 | |
Resolution: | Fixed | Closed By: | dgp | |
Closed on: | 2010-03-24 15:29:28 | |||
Description: |
% string is list "not \{ a list" 0 % catch {return -code error -errorcode "not \{ a list"} m o 2 % set m % set o -errorcode not\ \{\ a\ list -code 1 -level 1 The documentation is clear in return.n that -errorcode option takes a list argument. TclMergeReturnOptions() is failing to check that. | |||
User Comments: |
dgp added on 2010-03-24 22:29:28:
allow_comments - 1 Thanks for the patch. Committing to 8.5 and HEAD changing only the SetErrorCode arguments to better match what's been done before. ferrieux added on 2010-03-19 05:45:04: File Deleted - 367184: ferrieux added on 2010-03-19 05:44:50: File Added - 367318: errorcode.patch ferrieux added on 2010-03-19 05:43:57: D'oh of course :) Attaching patch, please review. dgp added on 2010-03-19 03:52:52: As noted in the original report, I think the place to fix this is in TclMergeReturnOptions(), not in TclProcessReturn(). ferrieux added on 2010-03-18 06:41:51: A simple way out would be in the non-compiled Tcl_ReturnObjCmd to exchange the two statements: code = TclProcessReturn(interp, code, level, returnOpts); if (explicitResult) { Tcl_SetObjResult(interp, objv[objc-1]); } yielding: if (explicitResult) { Tcl_SetObjResult(interp, objv[objc-1]); } code = TclProcessReturn(interp, code, level, returnOpts); however, doing the same in INST_RETURN_IMM in TEBC implies setting the result twice in the OK case (since the TOS ends up in the result), and I dare not (speed). Another option, as suggested before, is to add a high bit to TCL_ERROR, that would be intercepted immediately on return from TclProcessReturn, meaning TCL_ERROR_DURING_RETURN. Ugly too. Advice ? ferrieux added on 2010-03-18 06:07:21: File Added - 367184: return_errorcode.patch ferrieux added on 2010-03-18 06:06:45: Tiny attached patch barfs on non-list passed to [return -errorcode]. However, the exact error message is still [return]'s main argument (since it is called with -code error), because the caller of TclProcessReturn sets the interp result later. Maybe some kind of signalling should be devised to tell it about this special situation. |
Attachments:
- errorcode.patch [download] added by ferrieux on 2010-03-19 05:44:50. [details]