acornjs / acorn-jsx

Alternative, faster React.js JSX parser
MIT License
648 stars 74 forks source link

Whitespace not allowed after "}" in certain contexts #7

Closed Naddiseo closed 9 years ago

Naddiseo commented 9 years ago

Original report from downstream 6to5/acorn-6to5/issues/5:

The following all produce errors in the repl

var a = {} ;
var  a = ({} );
var a = b({} );
var a = <div>{ {a} }</div>;
var a = <div {...a} ></div>;

I've traced it down to the line while (!eat(_braceR)) { in the parseObj function. I think adding skipSpace() before the loop, and as the last thing in the loop, will fix the problem.

RReverser commented 9 years ago

Well, all the examples but var a = <div>{ {a} }</div>; work completely fine for me. Probably you just had corrupted state after JSX-specific errors and then tried other cases without restarting REPL.

Naddiseo commented 9 years ago

That example should still work: var a = <div>{ {1:1} }</div>; also fails.

RReverser commented 9 years ago

As you can see, it's already fixed in acorn-jsx (works fine to me with latest version).

sebmck commented 9 years ago

Works fine in the latest version of 6to5/acorn-6to5 too.