lambda-fairy/maud

Incorrect expression hygiene results in cryptic errors

mattfbacon opened this issue · 0 comments

Consider the following invocation:

html! {
  (1 + 1)
}

This expands to

{
    extern crate alloc;
    extern crate maud;
    let mut __maud_output = alloc::string::String::with_capacity(7usize);
    {
        use ::maud::macro_private::*;
        match ChooseRenderOrDisplay(&1 + 1) { // <- the problem
            x => (&&x)
                .implements_render_or_display()
                .render_to(x.0, &mut __maud_output),
        }
    };
    maud::PreEscaped(__maud_output)
}

Clearly &1 + 1 should have been &(1 + 1).

(Also, the String size hint is wrong.)