Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upEarly errors for invalid regular expressions #1050
Comments
rabbihyatt
referenced this issue
Dec 20, 2017
Closed
please be more assertive about the syntax errors pertaining to regular expressions #1051
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Or |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
RReverser
Dec 20, 2017
Contributor
Tested with Chakra on MacOS, it also treats this as an early parsing error. So it's only V8 that delays it to the runtime.
|
Tested with Chakra on MacOS, it also treats this as an early parsing error. So it's only V8 that delays it to the runtime. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mathiasbynens
Dec 20, 2017
Member
Specifically, the following script parses in V8, but not in SpiderMonkey or JavaScriptCore. I am not sure how it performs on ChakraCore.
$ eshost -e '(() => { if (false) /(/ })()'
#### Chakra
SyntaxError: Expected ')' in regular expression
#### JavaScriptCore
SyntaxError: Invalid regular expression: missing )
#### SpiderMonkey
SyntaxError: unterminated parenthetical:
#### V8 --harmony
undefined
#### V8
undefined
As a side comment, eshost-cli + jsvu make it really easy to test across all engines.
As a side comment, eshost-cli + jsvu make it really easy to test across all engines. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Dec 20, 2017
Collaborator
As it currently stands, the spec categorizes most invalid regular expression literals that don't interfere with parsing (e.g. /(/) as runtime errors ...
regular expression parsing errors only occur during Evaluation of such literals
What about the following early error?
It is a Syntax Error if BodyText of RegularExpressionLiteral
cannot be recognized using the goal symbol Pattern
of the ECMAScript RegExp grammar specified in 21.2.1.
What about the following early error?
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
closed this
Dec 20, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
TimothyGu
Dec 20, 2017
Member
@jmdyck Oops, I overlooked that one.
@littledan Thanks for confirming.
|
@jmdyck Oops, I overlooked that one. @littledan Thanks for confirming. |
TimothyGu commentedDec 20, 2017
•
edited
As it currently stands, the spec categorizes most invalid regular expression literals that don't interfere with parsing (e.g.
/(/) as runtime errors. (See grammar productions for RegularExpressionLiteral; regular expression parsing errors only occur during Evaluation of such literals, through RegExpCreate and RegExpInitialize steps 7 and 8.) However, it seems that many implementations treat them as early errors, as discovered in acornjs/acorn#640.Specifically, the following script parses in V8, but not in SpiderMonkey or JavaScriptCore. I am not sure how it performs on ChakraCore.
Alternatively, this could be used as a test: