"catch" doesn't catch "expr" syntax errors
Closed / Invalid219150ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 05:02:20
OriginalBugID: 1149 Bug
Version: 8.1b1
SubmitDate: '1999-02-02'
LastModified: '2000-05-19'
Severity: MED
Status: Assigned
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2248
OS: Linux
Machine: Other
FixedDate: '1999-04-09'
ClosedDate: '2000-10-25'
Name:
Steve McAndrewSmith
ReproducibleScript:
# These work fine
catch { expr 1+1 } ;# no error
catch { someundefinedproc } ;# error, but caught
# These don't! (the error is never caught)
catch { expr 1+- }
catch { expr int(abc) }
ObservedBehavior:
When "expr" generates a syntax error, it is not caught by the "catch" command.
DesiredBehavior:
Duh. :-) Catch should behave the same for "expr" as for any other error.
03/24/1999 14:23 - stanton - This is the expected (if non-obvious) behavior. The syntax error is detected during compilation of the catch command, so it cannot be masked. This is a change from 8.0 and should be documented more clearly.
---
04/09/1999 14:43 - surles - Added necessary documentation and an example.
--
This was originally noted fixed in 8.1b3, but it is actually a bug,
not a doc problem. The work-around is to do:
set cmd {expr 1+-}
catch $cmd
-- 05/19/2000 hobbs
dkfplain2000-11-08 18:56:51
Problem still exists. :^(
dgpplain2000-11-09 02:55:44
According to the release notes accompanying Tcl 8.0,
this is not a bug, but a known incompatibility with
Tcl 7 introduced by the bytecode compiler. Point 2
on page
http://dev.scriptics.com/doc/compiler.html
reads:
...
2.Catch no longer catches compilation errors
One consequence of the fact that in Tcl 8.0 compilation errors in scripts are returned immediately is that
catch no longer prevents compilation errors from aborting command interpretation. For example,
catch {set}
immediately reports the error
wrong # args: should be "set varName ?newValue?"
To have catch handle compile time errors, give it a script that is only determined at runtime: for example,
catch [concat {set}]
...
Perhaps this incompatibility wasn't a good idea, but it's
known and documented, so it's not a bug. I'm marking this
Invalid and Closing it. If you want this changed, file a TIP.
Log in (anonymous is fine) to add a comment.