Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl fails to generate visible errors under certain condition

Closed / Fixed218312ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:56:00
OriginalBugID: 3738 Bug
Version: 8.0p2
SubmitDate: '1999-12-01'
LastModified: '1999-12-03'
Severity: SER
Status: Closed
Submitter: techsupp
ChangedBy: hobbs
OS: Solaris
OSVersion: 2.6
Machine: Sun Sparc 1000, Windows 95 running the X-Windows emulator Xoftwa
FixedDate: '2000-10-25'
ClosedDate: '1999-12-03'


Name: Mark A. Wege

Comments:
This also happens using Tcl 7.4/Tk 4.0 on Unix, as well as Tcl 8.0.3 on Windows 95.

While writing the test script above, I also noticed that Tcl failed to inform
me of an error when I defined the checkvalue procedure without providing the
3 arguments required by the trace command.

ReproducibleScript:
The following script is part of some code we use to validate data that the user
types into entry widgets; this is done by placing traces on the entry widget's
textvariable.  To test this, either execute wish interactively and paste this
code into the session, or place the code into a file and then execute wish with
the file as a parameter:

proc checkvalue {args} {
   global e
   if {[string length $e] == 5} {
      after 500 {set e ""}
      puts "\nAbout to generate the error (undefined variable \"test\")"
      puts "test = $test"
      puts "after undefined variable"
   } else {
      puts "e = $e"
   }
}
label .l -text "Enter 5 characters to generate an error"
entry .e -textvariable e -width 10
button .b -width 10 -text "Enter Char" -command {append e c}
button .c -width 10 -text "Close" -command exit
pack .l .e
pack .b .c -side left -expand yes
focus .e
trace variable e w checkvalue

ObservedBehavior:
The trace procedure (checkvalue) is written such that the code attempts to
display the current value for an undefined variable when the entry widget
contains 5 characters.  This should generate an error, but doesn't always.
If you enter 5 characters manually, my first debug statement is displayed and
the trace procedure aborts, but no error is displayed, either in my xterm
window or in a popup window.  If you enter 5 characters by clicking on the
"Enter Char" button 5 times, a popup window containing the error is displayed.

DesiredBehavior:
Tcl should provide some visual indication that an error has occurred, either
by writing the error to stdout (when running interactively), or by displaying
the error in a popup window (using tkerror/bgerror).



This is by design.  The latter fails as expected, because it
occurs via the 'append' command.  However, the former is triggered
through the textvar tracing proc in the entry widget, which
ignores errors. The user can specifically do 'error' if they want. 
-- 12/03/1999 hobbs
welch Closed ticket [218312ffff]. [History diff]2000-10-26 08:19:00
dgp Ticket [218312ffff]: 3 changes [History diff]2001-04-16 20:42:28
Log in (anonymous is fine) to add a comment.