Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-03-29
11:58 • Ticket [545661ffff] bug in expr error handler status still Closed with 6 oth... artifact: fd6471538a user: dgp
2004-03-28
07:37 • Closed ticket [545661ffff]. artifact: 2d33744834 user: msofer
2003-11-13
08:29 • Ticket [545661ffff]: 1 change artifact: 2986cbd74f user: dgp
2002-04-18
13:59 • New ticket [545661ffff]. artifact: dfc8860250 user: msofer

bug in expr error handler

Closed / Invalid545661ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 23 years ago
Descriptionplain2002-04-18 13:59:02
There is an inconsistent behaviour in the [expr] error
handler: the moment when an invalid operand is detected
and an error is raised depends on the evaluation path
of the expression (compiled at compile-time vs at
run-time):

% set a 08
08
% expr $a - 1
"08" is an invalid octal number
% expr {$a - 1}
can't use invalid octal number as operand of "-"

The compiled-at-run-time version seems not to respect
the  expr.n manual page, which states:
"If no numeric interpretation is possible, then an
operand is left as a string (and only a limited set  of
operators may be applied to it)."

% set a 08
08
% expr $a == 1
"08" is an invalid octal number
% expr {$a == 1}
0

See also the (off-topic?) comments in [Bug #542588].
dgp Ticket [545661ffff]: 1 change [History diff]2003-11-13 08:29:27
msoferplain2004-03-28 07:37:42
Logged In: YES 
user_id=148712

Mmhh ... this is probably my misunderstanding of 'expr'; if
nobody else complains, I'll close this as invalid.
dgpplain2004-03-29 11:58:22
Logged In: YES 
user_id=80530

Looks like a distinction
between a parsing error
and an evaluation error.
Log in (anonymous is fine) to add a comment.