Skip to content
Tcl Source Code History Of Ticket 1e66ba3d49026071
Login

History Of Ticket 1e66ba3d49026071

Artifacts Associated With Ticket 1e66ba3d49026071

  1. Ticket change [63df456f61] (rid 258528) by serhiy.storchaka on 2026-10-17 10:51:11:

    1. cmimetype initialized to: "text/x-fossil-wiki"
    2. comment initialized to:
      A math function whose name is a word operator, or starts with one followed by a non-letter,
      cannot be called from <nowiki>[expr]</nowiki>, although mathfunc(n) says that any command
      defined in <tt>tcl::mathfunc</tt> becomes a function:
      
      <verbatim>
      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)}
      </verbatim>
      
      Both fail with <tt>missing operand</tt>, e.g.
      
      <verbatim>
      missing operand at _@_
      in expression "_@_in_range(5, 1, 10)"
      </verbatim>
      
      Expected: <tt>1</tt> and <tt>1</tt>, as for any other function name
      (<tt>inrange(5, 1, 10)</tt> works).
      
      Affected names: <tt>eq</tt>, <tt>ne</tt>, <tt>in</tt>, <tt>ni</tt>, and since 9.0 (TIP 461)
      also <tt>lt</tt>, <tt>le</tt>, <tt>gt</tt>, <tt>ge</tt>, alone or followed by a digit or an
      underscore (<tt>in_range</tt>, <tt>eq_zero</tt>, <tt>in1</tt>,
      <tt>lt_x</tt>, ...). <tt>lt_x(1)</tt> works in 8.6 and fails in 9.0.
      
      Cause: <tt>ParseLexeme</tt> in generic/tclCompExpr.c returns <tt>STREQ</tt>,
      <tt>IN_LIST</tt> etc. whenever the third character is not an ASCII letter, without regard to
      context; <tt>ParseExpr</tt> only turns a <tt>BAREWORD</tt> followed by <tt>(</tt> into a
      <tt>FUNCTION</tt>. Two possible fixes: in <tt>ParseExpr</tt>, treat a word operator that
      appears where an operand is expected and is followed by <tt>(</tt> as a function name (a binary
      operator is always an error there, so this is unambiguous); and in <tt>ParseLexeme</tt>, do not
      end the operator at <tt>_</tt> (<nowiki>[expr {$a eq_1}]</nowiki> is an error anyway). Digits
      are ambiguous, since <nowiki>[expr {$a eq1}]</nowiki> currently means <tt>$a eq 1</tt>.
      
      History: [ced7ccb24b] (2005, [1201589fff]) made the old parser accept <tt>eq</tt>,
      <tt>ne</tt>, <tt>in</tt>, <tt>ni</tt> 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 <tt>eq(1)</tt> too (<tt>unexpected operator eq</tt>). A
      similar problem for names starting with a number (<tt>nancy</tt>) was [3401704fff].
      
    3. foundin initialized to: "8.6.18, 9.0.5, 9.1.0"
    4. login: "serhiy.storchaka"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. severity initialized to: "Minor"
    8. status initialized to: "Open"
    9. subsystem initialized to: "45. Parsing and Eval"
    10. title initialized to:
      expr cannot call math functions named eq/ne/in/ni or starting with them (in_range, eq_zero, ...)
      
    11. type initialized to: "Bug"
  2. Ticket change [5df90f4a28] (rid 258597) by serhiy.storchaka on 2026-10-17 12:49:29:

    1. icomment:
      Proposed fix in branch [/timeline?r=expr-operator-prefixed-funcs|expr-operator-prefixed-funcs]: in <tt>ParseExpr()</tt>, a word operator where an operand is expected and followed by <tt>(</tt> is parsed as a function name, so <tt>in_range(5, 1, 10)</tt> and <tt>eq(1)</tt> work. Uses as operators (<tt>$a eq1</tt>, <tt>1eq1</tt>, <tt>$a ne(1)</tt>) are unchanged. Tests expr-bug-1e66ba3d49-1 and -2.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"
  3. Ticket change [96c419a066] (rid 259534) by serhiy.storchaka on 2026-10-20 18:11:29:

    1. submitter changed to: "serhiy.storchaka"