liquid icon indicating copy to clipboard operation
liquid copied to clipboard

Change Parser#expression to build the expression during strict parsing

Open peterzhu2118 opened this issue 5 years ago • 0 comments

Currently, the strict parser uses Parser#expression to build the string and then uses Expression.parse to parse the built string. Since Expression.parse is regex based, it has trouble parsing certain things (especially statements with parenthesis for order of operations).

An example of different behaviour between liquid and liquid-c is the (invalid) range (1..(1..5)). Liquid-c will correctly parse the range as from 1 to 1..5, and will raise a NoMethodError on 1..5 (due to calling to_i). But liquid parses it as a range of 1..(1 to 5). These two endpoints of the range will be treated as variables and passed to RangeLookup, which resolves both as nil, which Ruby resolves to the range 0..0.

peterzhu2118 avatar Nov 11 '20 19:11 peterzhu2118