babel icon indicating copy to clipboard operation
babel copied to clipboard

Minor bug in JavaScript lexer; failing to recognize numbers

Open andy0130tw opened this issue 4 years ago • 0 comments

There is a regex mistake:

https://github.com/python-babel/babel/blob/7ebdf5a249ff8861bbcd3f7e4cc1ba9555c3fb65/babel/messages/jslexer.py#L25

Here is how it is applied:

https://github.com/python-babel/babel/blob/7ebdf5a249ff8861bbcd3f7e4cc1ba9555c3fb65/babel/messages/jslexer.py#L41-L47

According to Python manual, \w matches [a-zA-Z0-9_], so a number literal of some small positive integer, e.g., 42, will always be recognized as a "name", not a number. This probably does not affect the result, but is a potential source of error when refactoring.

andy0130tw avatar Jun 06 '21 15:06 andy0130tw