While working on https://github.com/djc/askama/pull/862 fuzz_parser was
crashing and failing oss-fuzz build_checks. so a limit of 500 was placed, this pr removes that.
In the old implementation each variable in an expression would be parsed
up to three times:
* Try to parse a path because it contains a leading double colon, or
infix double colons.
* Try to parse it as path again by scanning for an identifier that
contains an upper case character.
* Fall back to scanning for any identifier.
This PR turns all three steps into one, without the need for
backtracking.
According to [RFC 1857] the fields of a struct are dropped in the same
order as they are declared. For `struct S { a: A, b: B }` field `a` is
dropped before field `b`.
Our struct `Parsed` is self referencial. Its field `ast` depends on
`source`, so `source` must outlife `ast`. This PR changes the order of
the fields to reflect this requirement. In practice it should not
matter, because we know that the variant of `Node` won't access the
string data during their `Drop`, but better safe than sorry - maybe
`Node` changes in the future.
[RFC 1857]: https://rust-lang.github.io/rfcs/1857-stabilize-drop-order.html
This change
* allows using empty arrays `[]` in expessions,
* adds a cut when the leading `[` was encountered, and
* fixes the interaction between arrays and boolean OR.
IMO the restriction that you couldn't use empty arrays is not needed.
The missing cut made error messages slictly worse if you forget to add
the closing `]`.
Filter expressions must not have white spaces before the pipe `|`. The
white space is used to tell a filter expressions, and `std::ops::Or`
apart.