expr cannot call math functions named eq/ne/in/ni or starting with them (in_range, eq_zero, ...)
proc tcl::mathfunc::in_range {x lo hi} {expr {$lo <= $x && $x <= $hi}}
proc tcl::mathfunc::eq {x} {return $x}
expr {in_range(5, 1, 10)}
expr {eq(1)}
Both fail with missing operand, e.g.
missing operand at _@_ in expression "_@_in_range(5, 1, 10)"
Expected: 1 and 1, as for any other function name (inrange(5, 1, 10) works).
Affected names: eq, ne, in, ni, and since 9.0 (TIP 461) also lt, le, gt, ge, alone or followed by a digit or an underscore (in_range, eq_zero, in1, lt_x, ...). lt_x(1) works in 8.6 and fails in 9.0.
Cause: ParseLexeme in generic/tclCompExpr.c returns STREQ, IN_LIST etc. whenever the third character is not an ASCII letter, without regard to context; ParseExpr only turns a BAREWORD followed by ( into a FUNCTION. Two possible fixes: in ParseExpr, treat a word operator that appears where an operand is expected and is followed by ( as a function name (a binary operator is always an error there, so this is unambiguous); and in ParseLexeme, do not end the operator at _ ([expr {$a eq_1}] is an error anyway). Digits are ambiguous, since [expr {$a eq1}] currently means $a eq 1.
History: [ced7ccb24b] (2005, [1201589fff]) made the old parser accept eq, ne, in, ni as function names in operand position. The new parser in 8.5a5 (2006; old parser dropped in [877cacc543]) does not, so no 8.5 or later release has supported it. 8.4.20 rejects eq(1) too (unexpected operator eq). A similar problem for names starting with a number (nancy) was [3401704fff].
bf736cdc73Fix [1e66ba3d49]: [expr] could not call math functions named eq, ne, in, ni, lt, le, gt, ge or starting with them followed by a digit or underscore (in_range). A word operator where an operand is expected and followed by ( is now parsed as a function name. check-in2026-10-17 12:48:40
Proposed fix in branch expr-operator-prefixed-funcs: in ParseExpr(), a word operator where an operand is expected and followed by ( is parsed as a function name, so in_range(5, 1, 10) and eq(1) work. Uses as operators ($a eq1, 1eq1, $a ne(1)) are unchanged. Tests expr-bug-1e66ba3d49-1 and -2.