|
2017-03-05
| ||
| 15:47 | • Ticket [71c0878b71] Strange results when second argument to incr is a list... artifact: aca3b4b8f1 user: avl42 | |
| 15:08 | • Closed ticket [71c0878b71]. artifact: 73ae80dd38 user: avl42 | |
| 15:05 | Fix for Ticket [71c0878b71] + test cases check-in: 154835dcb2 user: avl tags: trunk | |
| 14:35 | • Ticket [71c0878b71] Strange results when second argument to incr is a list... artifact: 1484e74dd0 user: avl42 | |
| 10:51 | • Ticket [71c0878b71]: 4 changes artifact: 184af92d8d user: avl42 | |
| 09:23 | • New ticket [71c0878b71]. artifact: 6268839aff user: anonymous | |
Strange results when second argument to [incr] is a list
Closed / Fixed71c0878b712d056d9c69dba6f72e0efce751e290Created 10 years agoUpdated 10 years ago
Descriptionplain2017-03-05 09:23:52
First case (the variable "var" does not exist):
% incr var {1 2}
--> expected integer but got "1 2"
This is the expected result.
Second case (the variable "var" does not exist):
% incr var [list 1 2]
--> can't read "var": no such variable
The error message is very misleading, as for [incr] the variable needs not to exist.
Third case: this time we create "var" before [incr]easing it:
% set var 1
--> 1
% incr var [list 1 2]
-->
% set errorInfo
(reading increment)
invoked from within
"incr var [list 1 2]"
In this case the error message is the empty string.
The problem does not show in 8.6.6
Referenced by1
154835dcb2Fix for Ticket [71c0878b71] + test cases check-in2017-03-05 15:05:48
avl42plain2017-03-05 10:51:36
bisecting points to commit b4792ebcec7a8473 " Shortcut in TclParseNumber(): If obj is a dict or list, " don't bother to generate the string representation if we know already " beforehand that the parsing will fail. Use TCL_NO_DEPRECATED in stead " of KILL_OCTAL for removing the (deprecated un-prefixed) octal support. " Adapt test-cases, so they work without octal support as well.
avl42plain2017-03-05 14:35:29
Maybe that's obvious, anyway, but the new code to detect definitely-not-numbers only returns TCL_ERROR but doesn't set an error result string. The consequence is that eventually a previously suppressed error resurfaces, or just an empty string.
For full correctness, we would need to ensure the same error message on a pure list/dict than on its canonical string rep. Fortunately, we only need to do this, if the interp is non-NULL, so the intended speed-up for tryCvtToNumeric isn't affected, as it already passes NULL for the interp.
My suggested fix would be to change line 542 ("if (endPtrPtr ...") to "if (interp==NULL && endPtrPtr == NULL) ...". If there is an interp, we need an authentic error diagnose, so can't shortcut.
avl42plain2017-03-05 15:08:26
Fixed in commit 154835dcb2
avl42plain2017-03-05 15:47:06
Afternote: the fix preserves the optimisations for tryCvtToNumeric:
% set x [lrepeat 1000000 "*"]; set y [lrepeat 1000000 $x]; llength $y
1000000
% llength [expr {$y}]
1000000
Without the optimisation this crashes with "max size for a Tcl value (2147483647 bytes) exceeded".
Log in (anonymous is fine) to add a comment.