Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2006-07-05
12:35 • Closed ticket [1029267fff]: bad expr syntax error message plus 7 other cha... artifact: 897e50f310 user: dgp
2006-06-02
00:06 • Ticket [1029267fff]: 4 changes artifact: d5b015ffc2 user: flatworm
2006-03-31
23:18 • Ticket [1029267fff]: 1 change artifact: f4e87d6840 user: dgp
2006-03-10
13:41 • Ticket [1029267fff]: 2 changes artifact: 65f4c1dd97 user: dgp
2004-09-20
00:11 • Ticket [1029267fff]: 4 changes artifact: 60737afc26 user: dkf
2004-09-19
22:20 • Ticket [1029267fff]: 4 changes artifact: 9b956b3ee7 user: msofer
21:24 • Ticket [1029267fff]: 4 changes artifact: 9b6bddbb1b user: msofer
21:18 • Ticket [1029267fff]: 4 changes artifact: db03ce60f9 user: msofer
2004-09-16
15:22 • New ticket [1029267fff]. artifact: 5362beb166 user: dgp

bad [expr] syntax error message

Closed / Fixed1029267fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 20 years ago
Descriptionplain2004-09-16 15:22:33
% expr 1=2 
syntax error in expression "1=2": extra tokens at end
of expression


The error message
"single equality character not legal in expressions"
is present in tclParseExpr.c and would
be more fitting here.  Why isn't it returned?
msoferplain2004-09-19 21:18:04
Logged In: YES 
user_id=148712

Oh my ... the whole "wrong lexeme type" section of
ParsePrimaryExpr() seems non-functional. Another example is
 % expr 1,2
 syntax error in expression "1,2": extra tokens at end of
expression

What is happening is that the parser sees the '1' as a
complete literal expression, and complains about '=2' or
',2' or 'a2' following it. The correct message is produced
for [expr =2], as the first lexeme is the bare = sign.

Another beauty:
% expr (1=2)
syntax error in expression "(1=2)": looking for close
parenthesis
msoferplain2004-09-19 21:24:32
Logged In: YES 
user_id=148712

At least some of the tests (notably parseExpr-16.33) expect
this behaviour.
msoferplain2004-09-19 22:20:08
Logged In: YES 
user_id=148712

Another one:
% expr cos(1=2)
syntax error in expression "cos(1=2)": missing close
parenthesis at end of function call

What is happening is that the expr parser considers the
subexpression '1=2' finished at the '1', with extra tokens
'=2)'.
dkfplain2004-09-20 00:11:08
Logged In: YES 
user_id=79902

Getting sensible failures out of a parser is notoriously
difficult. At least we aren't in the previous situation
where all the parser would say was "syntax error", which was
singularly uninformative in complex expressions...
dgp Ticket [1029267fff]: 2 changes [History diff]2006-03-10 13:41:39
dgp Ticket [1029267fff]: 1 change [History diff]2006-03-31 23:18:06
flatwormplain2006-06-02 00:06:54
Logged In: YES 
user_id=1350198

A kind of "silent error" when just one double quote is
passed to the expr:

% if {"} { puts then } else { puts else }

% set errorCode
NONE
% set errorInfo

    while executing
"if {"} { puts then } else { puts else }"

On the other hand,
if {(")} ...
produces the sensible error message:
missing "
dgpplain2006-07-05 12:35:19
Logged In: YES 
user_id=80530

fixed in 8.5a5
Log in (anonymous is fine) to add a comment.