| (pipe) has the highest precedence, contradicting the README; {{= user.name | uppercase() }} fails to parse #20

Closed
opened 2026-08-07 13:33:05 +02:00 by Hemera · 0 comments
Owner

The README states: "The | operator has the lowest precedence of the operators."

In src/parser/mod.rs:973 the pipe is registered as Left(99). Winnow's Pratt parser treats higher numbers as tighter binding, so | is currently the tightest operator — above postfix ?/[ (23) and . (22).

Consequences (both verified against main):

  • {{= user.name | uppercase() }}parse error. The . parses its rhs at min-power 23, but | (99) binds tighter, so the rhs becomes name | uppercase(), which the Dot rhs-restriction rejects.
  • {{= foo | f().name }} parses as (foo | f()).name (opposite of what "lowest precedence" implies).

Fix: give | the lowest precedence (e.g. below || at 7). Then user.name | uppercase() parses as (user.name) | uppercase() while foo? | or_default("Unknown") still works (? is postfix, binds tighter).

The README states: *"The `|` operator has the lowest precedence of the operators."* In `src/parser/mod.rs:973` the pipe is registered as `Left(99)`. Winnow's Pratt parser treats higher numbers as tighter binding, so `|` is currently the **tightest** operator — above postfix `?`/`[` (23) and `.` (22). Consequences (both verified against `main`): - `{{= user.name | uppercase() }}` → **parse error**. The `.` parses its rhs at min-power 23, but `|` (99) binds tighter, so the rhs becomes `name | uppercase()`, which the Dot rhs-restriction rejects. - `{{= foo | f().name }}` parses as `(foo | f()).name` (opposite of what "lowest precedence" implies). Fix: give `|` the lowest precedence (e.g. below `||` at 7). Then `user.name | uppercase()` parses as `(user.name) | uppercase()` while `foo? | or_default("Unknown")` still works (`?` is postfix, binds tighter).
Sign in to join this conversation.
No labels
automated-🤖
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Hemera/nomo#20
No description provided.