chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Pratt parser postfix documentation contains incorrect accepted function signature.

Open BotAngus opened this issue 5 months ago • 0 comments

The documentation for the pratt parser postfix function states that the accepted function signatures are the following.

// Transform the operand
impl Fn(O) -> O
// Combine the operand and the operator itself
impl Fn(O, Op) -> O
// Combine the operand, the operator itself, and a [`MapExtra`] covering the whole operation
impl Fn(Op, O, &mut MapExtra<'a, '_, I, E>) -> O

Instead it should be

// Transform the operand
impl Fn(O) -> O
// Combine the operand and the operator itself
impl Fn(O, Op) -> O
// Combine the operand, the operator itself, and a [`MapExtra`] covering the whole operation
impl Fn(O, Op, &mut MapExtra<'a, '_, I, E>) -> O

as seen in the macro that implements it. (Note that the last signature switched from Op, O to O, Op, the latter one lining up with the order the arguments appear in syntactically.)

BotAngus avatar Sep 08 '24 23:09 BotAngus