fix js exception due to regex flags #8887
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
in ESTree, the
value
property of a regex is an instantiatedRegExp
object. if it can't be represented for some reason, thevalue
should benull
. there is also aregex
property with the pattern and flags as strings so you can still tell what it was.JSON doesn't have regexes, so
flow ast
already returns null.flow_parser.js
runs in a JS engine so it does try to create aRegExp
. when creating aRegExp
fatals, we previously tried to recover in a bogus way. it should returnnull
instead.this fixes a crash when the browser engine doesn't support the latest regex flags, like
y
,u
ord
.Fixes #8886
Changelog: [parser] Fix a runtime exception when parsing regexes via the JS version of the parser
Differential Revision: D36754295