Skip to content

Incorrect error output for mistakes in HTML fragments #1444

Closed
@ilyvion

Description

@ilyvion

Problem
The macro parser doesn't correctly handle errors in HTML fragments.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Put the following into a html! invocation:
        html! {
            <key="key" key="key">
                <div>{ "Hello World!" }</div>
            </>
        };
  2. Attempt to compile the code
  3. See that the error you get is "error: unexpected token"

Expected behavior
If you look at the code in yew-macro\src\html_tree\html_list.rs,

impl Parse for ParseKey {
fn parse(input: ParseStream) -> ParseResult<Self> {
let key = input.parse::<HtmlProp>()?;
if !input.is_empty() {
input.error("Only a single key element is allowed on a <></>");
}
Ok(ParseKey { key })
}
}

the intended error message here is clearly meant to be

Only a single key element is allowed on a <></>

Environment:

  • Yew version: master
  • Rust version: 1.44

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions