booleans break EIAS
Closed / Fixed1187123fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-04-21 05:38:05
% set x 5 5 % string is boolean $x 0 % namespace ensemble create -prefixes $x :: % string is boolean $x 1 % set x 5 So $x is/is not a valid boolean depending on its Tcl_ObjType. Foundation of the bug is that Tcl_GetBoolean and Tcl_GetBooleanFromObj are inconsistent in the sets of strings they accept as valid boolean values.
dgpplain2005-04-21 13:09:59
Logged In: YES
user_id=80530
Also lurking here is the inconsistency
in the set of values that pass
string is boolean -strict $x
and the set of values that do not
raise an error in:
expr {$x && $x}
Consider $x having value "5"
or "0xface" or "3.14159".
All rejected by [string is boolean]
(unless shimmering confuses)
but all accepted by [expr] as
operands to its boolean operators.
msoferplain2005-04-21 19:01:27
Logged In: YES
user_id=148712
Re the second comment: that is ok according to the docs.
The boolean operators take as arguments booleans *or*
numbers, and produce an integer 0/1 result - according to
both the [expr] man page and TEBC.
[string is boolean] OTOH is supposed to only recognise the
forms 0/1, yes/no, on/off and true/false according to the
[string] and Tcl_GetBoolean manuals. In other words,
[string is boolean $x]
is not supposed to coincide with
[expr ![catch {expr $x && $x}]]
msoferplain2005-04-21 19:14:51
Logged In: YES
user_id=148712
The function that does not agree with the docs is
Tcl_GetBooleanFromObj: what the code does is return the
value of [expr !!$x] (or an error). What the docs say it
does is identical to Tcl_GetBoolean.
The part that is wrong is branded as
/*
* Use the obvious shortcuts for numerical values; if
objPtr is not
* of numerical type, parse its string rep.
*/
Obvious maybe ... but wrong. This provides a
"Tcl_GetTruthValueFromObj" or something like that.
dgpplain2005-04-22 03:24:11
Logged In: YES user_id=80530 committing fix to HEAD. Backport will require some more effort.
dgpplain2005-04-22 22:54:18
Logged In: YES user_id=80530 corrected fix committed to HEAD. still needs backport.
dgpplain2005-04-22 23:31:03
Logged In: YES user_id=80530 More cautious fix committed for 8.4.10.
Log in (anonymous is fine) to add a comment.