Conversation
Huxpro
left a comment
There was a problem hiding this comment.
I'm still waiting for Flow team to give a response but other than that (and a question), this LGTM.
| <ins>JSXElement</ins> | ||
| <ins>JSXFragment</ins> | ||
| PrimaryExpression :: | ||
| <ins>JSXElementOrFragment `<`</ins> |
There was a problem hiding this comment.
Do we need this production to be able to define an early error on PrimaryExpression :: JSXElementOrFragment <?
There was a problem hiding this comment.
We could do something like
PrimaryExpression :: JSXElementOrFragment
- It is a Syntax Error is this production is followed by the `<` token
but I used that new production to avoid introducing new language/checks that are not already used in the ecma262 spec
There was a problem hiding this comment.
I understand that without PrimaryExpression :: JSXElementOrFragment < we don't have a production to match with. But it's also not ideal to me to only add this production specifically for the early error 🤔
There was a problem hiding this comment.
Note that the ecma262 spec already does this in a few cases, for example to disallow a?.b`c`: https://tc39.es/ecma262/#sec-left-hand-side-expressions-static-semantics-early-errors
Co-authored-by: Xuan Huang (黄玄) <huxpro@gmail.com>
Huxpro
left a comment
There was a problem hiding this comment.
Came across and I think this LGTM.
It may be nicer if we could have a note like https://tc39.es/ecma262/#sec-left-hand-side-expressions-static-semantics-early-errors to say something similar:
This production (only) exists in order to prevent ...
As I'm no longer employed by Meta, we will need some help to actually merge this. cc @poteto if anyone on the team is interested in taking a look.
Fixes #120.
This was quite hard to specify:
RelationalExpressionsaying something like "It is a SyntaxError if the left side of the expression recursively contains aJSXElementOrFragmentas its right-most descendent.", but it would have required writing some custom sdo for every production that can derive aJSXElementOrFragmentas a child ofRelationalExpression.