Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2004-10-04
20:58 • Closed ticket [884830ffff]: Expr Parser Permits Syntax Error plus 7 other ch... artifact: 65fedfba2d user: dkf
20:24 • Ticket [884830ffff]: 4 changes artifact: dbb506c5fa user: dkf
2004-02-14
05:25 • Ticket [884830ffff]: 5 changes artifact: e15cbbd9b2 user: hobbs
2004-01-27
18:06 • Ticket [884830ffff]: 5 changes artifact: 0edb6a1b35 user: dkf
2004-01-26
23:49 • Ticket [884830ffff]: 4 changes artifact: b12acb01c4 user: rmax
15:56 • New ticket [884830ffff]. artifact: c2881fe00e user: dkf

Expr Parser Permits Syntax Error

Closed / Fixed884830ffffffffffffffffffffffffffffffffffCreated 23 years agoUpdated 22 years ago
Descriptionplain2004-01-26 15:56:11
Shouldn't the following be a syntax error:
   expr {false eqfalse}
and also this:
   expr {1eqint(2)}It looks to me like the 'eq' (and
'ne' too) operator doesn't check that it is not
immediately followed by another character that could
form part of a continuous literal or function name.
rmaxplain2004-01-26 23:49:21
Logged In: YES 
user_id=124643

Another question is how 1eq1 should be handled. Currently it
is allowed, and exercised by the test suite. Although the
respective tests (expr-7.14, and expr-8.14 .. expr-8.17)
don't explicitely state that they are meant to test eq and
ne without white space around the operator.
dkfplain2004-01-27 18:06:30
Logged In: YES 
user_id=79902

I think it is best for the expression parser to at least
check that the letters 'eq' and 'ne' are not followed by an
alphabetic character.

Note for Tcl9: supporting '2eq2' as an expression is a
really bad idea since it may interfere with
application-defined functions. We should fix the lexer to be
more conventional (which is probably what Jeff's original
intention was, after all.  I suspect '2eq2' was really an
unintended side effect).

Assigning to Jeff for his input, as he was the creator of
the 'eq' and 'ne' operators in the first place.
hobbsplain2004-02-14 05:25:12
Logged In: YES 
user_id=72656

The support for things like 2eq2 was actually intentional
and something I had to make work solely because 2==2 is
supported, but prior to the changes for recognized unquoted
booleans, there were no other possibilities of conflicts. 
0eqfalse used to be a syntax error because it had to be at
least 0eq"false", which is more clearly separated.  Now that
that is blurred with bare booleans, I suspect a check for
!alpha is correct, although I don't agree that 2eq2 should
become an error right now.
dkfplain2004-10-04 20:24:36
Logged In: YES 
user_id=79902

We always should have done that in parsing because we allow
user-defined function names (though thankfully very few
people actually do this!) and have (officially) no reserved
letter sequences there.
dkfplain2004-10-04 20:58:01
Logged In: YES 
user_id=79902

Fixed in HEAD. Can't be bothered to backport; most people
won't be hit by this fault.
Log in (anonymous is fine) to add a comment.