produced a MemberExpression with the object being 1 and the property being 5. The reason was that matchNumber() in Lexer.js, when encountering a . in a number, prepared to read a series of decimals. In this case, it did not encounter anything, aborted, and produced a Number token with the text 1., which is a valid JavaScript number, but not a valid number in Twig (try, for example, {{ 1. }} on https://twigfiddle.com/).
This PR fixes this bug by looking ahead one additional character, and only going into decimal detection when there is a digit after the ..
Previously, the expression
produced a
MemberExpression
with the object being1
and the property being5
. The reason was thatmatchNumber()
inLexer.js
, when encountering a.
in a number, prepared to read a series of decimals. In this case, it did not encounter anything, aborted, and produced aNumber
token with the text1.
, which is a valid JavaScript number, but not a valid number in Twig (try, for example,{{ 1. }}
on https://twigfiddle.com/).This PR fixes this bug by looking ahead one additional character, and only going into decimal detection when there is a digit after the
.
.