|
2014-08-07
| ||
| 09:53 | • Ticket [2935779fff] Incorrect -errorline from compiled catch status still ... artifact: 2a3a6ca520 user: dkf | |
|
2014-08-06
| ||
| 17:06 | • Ticket [2935779fff]: 7 changes artifact: c6bdf25a39 user: msofer | |
|
2013-03-20
| ||
| 01:44 | • Ticket [2935779fff]: 5 changes artifact: 4fbab61cd7 user: dgp | |
|
2012-08-25
| ||
| 07:51 | • Ticket [2935779fff]: 2 changes artifact: 7b2f23631b user: dgp | |
| 00:55 | • Ticket [2935779fff]: 4 changes artifact: efef3d5cda user: duquette | |
|
2010-02-18
| ||
| 02:12 | • Ticket [2935779fff]: 5 changes artifact: 63166364a2 user: dgp | |
|
2010-01-21
| ||
| 16:30 | • Ticket [2935779fff]: 4 changes artifact: c65f2210a2 user: dzach | |
| 09:27 | • Ticket [2935779fff]: 4 changes artifact: cfade21358 user: dzach | |
| 09:15 | • Ticket [2935779fff]: 6 changes artifact: 91a3ff2f61 user: dgp | |
|
2010-01-20
| ||
| 18:57 | • New ticket [2935779fff]. artifact: cd3df63324 user: dzach | |
Incorrect -errorline from compiled [catch]
Open2935779fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 12 years ago
Descriptionplain2010-01-20 18:57:49
The documentation states:
"catch script ?resultVarName? ?optionsVarName?"
... "The value of the -errorline entry is an integer indicating which line of script was being evaluated when the error occurred."
However, if one runs some [catch] code inside a proc, the -errorline integer indicates the line of the proc script that has the error and not the line of the catch script, as is stated in the doc. The following code shows the problem:
proc test {} {
puts inside...\[test]
puts "some more text"
switch {} {
default {
catch {
puts "inside script"
sdfsdf # the error
} err opt
}
}
puts $err
puts $opt
}
% test
inside...[test]
some more text
inside script
invalid command name "sdfsdf"
-code 1 -level 0 -errorcode NONE -errorinfo {invalid command name "sdfsdf"
while executing
"sdfsdf # the error"} -errorline 8
instead of -errorline 3
dgpplain2010-01-21 09:15:50
That's a bug then, not mistaken docs. Please state precisely what release you see this buggy behavior in, and whether or not it is a regression from earlier releases that got things right.
dzachplain2010-01-21 09:27:55
Release: Tcl8.6b1.1 / Tk8.6b1.1 Same problem with: Tcl8.5a6 / Tk8.5a6 but not with Tcl8.4.16 / Tk8.4.16 since [catch] options were introduced in 8.5 I think.
dzachplain2010-01-21 16:30:55
I don't call it a bug because I find the functionality correct and as expected, only the docs say it should be different. The way it works now helps pinpoint the error line within the [proc] script, with a simple [info body].
dgpplain2010-02-18 02:12:39
Contrast these two:
% proc test {} {
catch {
puts foo
error bar
} m o
puts $o
}
% test
foo
-code 1 -level 0 -errorcode NONE -errorinfo {bar
while executing
"error bar"} -errorline 4
% proc test2 {} {
set catch catch
$catch {
puts foo
error bar
} m o
puts $o
}
% test2
foo
-code 1 -level 0 -errorcode NONE -errorinfo {bar
while executing
"error bar"} -errorline 3
The difference is whether [catch] is compiled,
and when it is, it becomes intstructions within
the larger proc body script which causes
GetSrcInfoForPc() to base its errorLine calculation
off the wrong script start.
Will get back to this one later.
duquetteplain2012-08-25 00:55:12
I'm seeing this bug in Tcl 8.5.9 on Mac OS X; and it simply isn't a documentation bug. Getting the errorline in the enclosing proc isn't useful.
dgp Ticket [2935779fff]: 2 changes
[History diff]2012-08-25 07:51:20
dgpplain2013-03-20 01:44:35
miguel, any thoughts on this one? Also, don't we have other commands besides [catch] that compile script bodies into inline bytecodes that would suffer the same problem?
msoferplain2014-08-06 17:06:40
Nothing much to say on this.
dkfhtml2014-08-07 09:53:49
I think it's been this was since 8.0a1, though you'll have to parse the $::errorInfo to get the line number there.
Log in (anonymous is fine) to add a comment.