govaluate icon indicating copy to clipboard operation
govaluate copied to clipboard

Variable names equal to expression functions cause problems

Open maja42 opened this issue 7 years ago • 1 comments

Let's say I define an expression function str(...) that takes a single argument and converts it into a string. Now, when I have a variable with the same name ("str"), the expressions cannot be parsed anymore.

I get the following error: Cannot transition token types from FUNCTION [0x70b700] to CLAUSE_CLOSE [41]

Apparently, functions are not detected due to the round brackets, but due to their name. So they can clash with variable names.

maja42 avatar Jun 13 '18 07:06 maja42

Yes, that's the behavior. The parser treats all unescaped strings of characters as a variable - unless it finds a function with that name in the function map. This isn't a bug, but I can probably make it more clear in the docs that name ambiguity isn't supported in this library.

Knetic avatar Oct 20 '18 19:10 Knetic