TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
559 stars 90 forks source link

Object's prototype methods return undefined for token type #118

Open ozanbatuhanceylan opened 2 years ago

ozanbatuhanceylan commented 2 years ago

I wanted to add custom toLocaleString method as expression but i realized that createToken function checks elements of grammar to identify token type.

else if (this._grammar.elements[element]) {
        token.type = this._grammar.elements[element].type;
}

Elements don't have toLocaleString key but due to object inheritance it has toLocaleString method and it returns undefined for type.

I want to make sure that should i define reserved keywords for naming custom expressions or is this a bug which is have to fixed.