Ticket UUID: | 681841 | |||
Title: | odd error message with missing character | |||
Type: | Bug | Version: | obsolete: 8.4.1.1 | |
Submitter: | vincentdarley | Created on: | 2003-02-06 18:41:59 | |
Subsystem: | 45. Parsing and Eval | Assigned To: | dgp | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2003-02-17 03:20:46 | |
Resolution: | Fixed | Closed By: | dgp | |
Closed on: | 2003-02-16 20:20:46 | |||
Description: |
This script, when evaluated (note the missing closing square bracket): catch { if {![catch [list foo]} { } } err puts $err puts $errorInfo gives me: invalid command name "fo" while executing "fo" invoked from within "catch [list foo" i.e. 'err' is empty, and errorInfo has somehow dropped the last 'o' from foo. Both of these seem incorrect. | |||
User Comments: |
dgp added on 2003-02-17 03:20:46:
Logged In: YES user_id=80530 the bug is fixed. Other changes will be dealt with in other reports. msofer added on 2003-02-16 08:49:33: Logged In: YES user_id=148712 Reviewed, teste, committed. Assigning to dgp for the [subst] fixes - or else, for branching the subst bugs to another ticket and closing thisone dgp added on 2003-02-14 01:08:45: File Added - 42334: 681841-final.patch dgp added on 2003-02-14 01:08:41: Logged In: YES user_id=80530 Here's the final version of the patch. Ambitious changes to [subst] have been removed. Just the bug fix, ma'am. Please review, test, and commit. dgp added on 2003-02-13 23:46:51: Logged In: YES user_id=80530 yes, for the sake of good patch-release compatibility, I am separating the bug fix patch from the "improve subst" patch. update soon. dkf added on 2003-02-13 23:39:18: Logged In: YES user_id=79902 Ultimately, the behaviour of [subst] is strange in so many ways in these edge cases. Given that, it's hard to believe that many people are encountering them, so fixing them any way you like (especially if it is more consistent with the documentation of the command) will be no problem. Perhaps the alteration of that aspect should wait for 8.4.2 to be branched off though, for maximum backward compatability. dgp added on 2003-02-13 23:07:19: Logged In: YES user_id=80530 I'm having second thoughts about tests subst-10.4 and subst-10.5. In those tests a [break] is being used to halt substitution. In that case, it seems strange for a parse error beyond the [break] to cause an error. Thoughts? dkf added on 2003-02-13 21:57:57: Logged In: YES user_id=79902 OK, I prefer the behaviour of [subst] forced by these changes. It's even less surprising given the documentation of the command as being like substitution inside a "quoted" string; we're actually closer to the documentation with this alteration! Go ahead and modify subst.test so that the following tests do not fail: subst-8.6, subst-8.7, subst-8.8, subst-10.4, subst-10.5, subst-11.4, subst-11.5 dkf added on 2003-02-13 21:31:50: Logged In: YES user_id=79902 And people wonder why Tcl_SubstObj has undefined behaviour... dgp added on 2003-02-13 08:46:21: File Deleted - 42217: File Added - 42249: 681841.patch dgp added on 2003-02-13 08:46:20: Logged In: YES user_id=80530 another updated patch. Now includes changes to Tcl_EvalEx in tclBasic.c No more code changes to make. With this patch, 8 tests in subst.test fail, but arguably they are testing bugward compatibility, and the new behavior is better. Assigning to the [subst] maintainer for his opinion on that. dgp added on 2003-02-13 01:36:19: File Deleted - 41816: File Added - 42217: 681841.patch Logged In: YES user_id=80530 Here's an updated patch that takes care of updating tclCompile.c. More bugs fixed, and ::errorInfo trace should now be improved when parsing errors occur. Please review. Still more work to do on Tcl_EvalEx. dgp added on 2003-02-08 08:10:18: Logged In: YES user_id=80530 Here's another demo of the original bug: % if {1 && "" == [puts \]} {} \ Note that a backslash is printed, not a ] ! dgp added on 2003-02-08 07:18:04: File Deleted - 41799: File Added - 41816: 681841.patch Logged In: YES user_id=80530 Here is an updated patch that also includes a fix for Tcl_EvalEx(). I suspect there are still errors involving the setting of iPtr->termOffset. Not ready to commit yet. dgp added on 2003-02-08 06:29:29: Logged In: YES user_id=80530 There is a similar error in Tcl_EvalEx() that can be demo'd by subst {a[set b [format cd]} no syntax error reported. msofer added on 2003-02-08 03:57:21: Logged In: YES user_id=148712 Patch looks good! Q: does it also solve the old bug you mentioned? (I never got around to understanding what it is ...) dgp added on 2003-02-08 03:30:09: File Added - 41799: 681841.patch Logged In: YES user_id=80530 please review this patch. dgp added on 2003-02-08 02:06:40: Logged In: YES user_id=80530 patch coming soon. dkf added on 2003-02-07 23:16:13: Logged In: YES user_id=79902 I don't know which function has responsibility for stripping the close bracket. The open bracket is obviously consumed by ParseTokens(), but who gets the close? dkf added on 2003-02-07 23:13:56: Logged In: YES user_id=79902 Further investigation seems to indicate the problem as being that when parsing bracketed things, the trailing bracket is consumed by Tcl_ParseCommand, stopping us from telling whether it should have done so. Perhaps. Everything's so recursive it's hard to tell for sure... dkf added on 2003-02-07 22:32:43: Logged In: YES user_id=79902 Obviously not (or we barf on init.tcl!) :^/ dkf added on 2003-02-07 22:30:07: Logged In: YES user_id=79902 Yes, shouldn't the tests there come after the test to see if the end of the string has been reached? dkf added on 2003-02-07 22:28:17: Logged In: YES user_id=79902 I suspect a problem near tclParse.c:865 msofer added on 2003-02-07 18:59:12: Logged In: YES user_id=148712 Debug notes RE the new error: something subtle going on, witness % set x {set a [format bc]} set a [format bc] % set y [string range $x 0 15] set a [format bc % testparser $x 16 - {set a [format bc} 3 simple set 1 text set 0 simple a 1 text a 0 word {[format bc} 1 command {[format bc} 0 \] % testparser $y 16 missing close-bracket dgp added on 2003-02-07 13:46:57: Logged In: YES user_id=80530 Curious. There is a parsing error there, but there always has been. Before, Tcl would parse the expression wrong, allowing the error to go unnoticed, but then the compiler would raise an error when trying to compile the command substitutions in the expr. The *new* error is that Tcl_ParseCommand itself is buggy in handling strings that have a ] following the string to be parsed. See this with testparser {set a [format bc]} 16 in both 8.3 and 8.4. (length 16 does not include the closing ]. Thus a parse error in 8.3, but a mistaken acceptance in 8.4, apparently due to an effective read beyond numbytes when parsing.) Both errors should be fixed. dgp added on 2003-02-07 05:28:24: Logged In: YES user_id=80530 Error is in parsing nested command evaluations in an expression. Simpler test case: expr {[set a [format bc]} Miguel, error should be found in lines 1261-1313 of tclParseExpr.c dgp added on 2003-02-07 05:22:31: Logged In: YES user_id=80530 Ouch! Note that the return from [catch] here is TCL_OK, not TCL_ERROR ! dgp added on 2003-02-07 04:58:02: Logged In: YES user_id=80530 Therefore my parser rewrite is likely to blame. msofer added on 2003-02-07 02:17:41: Logged In: YES user_id=148712 AIEEEEE! Mem corruption in the parser? Introduced between 8.4b1 and 8.4b2 ... |