Skip to content

[bug] Filter pipe | has lower precedence than comparison operators #4

@thwbh

Description

@thwbh

Module

core

Version

0.1.1

Environment

OS: macOS 15.5
Rust: 1.77.2

Description

In parse_filter_expr(), the pipe | is parsed at the outermost expression level (after parse_ternary()). This means {#if items | length > 0} is parsed as items | (length > 0) rather than (items | length) > 0, causing a parse error because length > 0 isn't a valid filter name.

In Tera and Jinja2, {{ items | length > 0 }} works as expected because the pipe binds tighter than comparison. In gracile, every comparison against a filtered value requires explicit parentheses: {#if (items | length) > 0}.

This is arguably a bug in the expression grammar rather than a feature request, since the current behavior means expr | filter == value silently fails to parse in a way that doesn't match user expectations or prior art from other template engines.

Code Sample

Fails:  {#if items | length > 0}
Error:  Expected '}', got Gt

Works:  {#if (items | length) > 0}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions