Skip to content

Parse error is confusing when trying to return two elements #1584

Closed
facebookarchive/esprima
#20
@sophiebits

Description

@sophiebits

(Opening here because esprima-fb apparently doesn't accept issues.)

If you write

return <div className="one" /><div className="two" />;

then you get "Unexpected identifier" because it tries to parse it as

return React.DOM.div({className: "one"})  < div className ...

That is, the < of the second div is interpreted as a less than. I think we can give nicer errors here if we disallow the less than operator directly after an XJSElement. I don't think this prevents any real uses but if it did, you could always wrap it in parens:

return (<div className="one" />) < threshold;

cc @jeffmo @syranide

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions