-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\s optimization changes runtime semantics #81
Comments
Good catch! In practice though, as you mentioned, I'd consider it as an edge case. The "loose" mode sounds interesting, or we can just handle a white/black list of needed transforms, and exclude some transform if it changes the semantics on practice. |
I just wonder if people ever put such an explicit list of whitespace characters but mean |
Yeah, let’s not change runtime semantics. |
OK, need to think about it. Depending on how often the use-case is, we can either exclude the |
I don't think keeping it as-is is a very good idea, especially if it's rarely used, since then it can just bite silently much later in runtime. |
As per ECMAScript spec,
\s
matches any WhiteSpace or LineTerminator character:Currently optimizer docs say it transforms
[ \t\r\n\f]
to\s
(and the opposite), but this changes runtime semantics of the RegExp as in fact\s
matches many more characters:I don't know if this is an intentional deviation and these are considered as edge cases that should be ignored, but it would be nice to make such "loose" transformations at least optional under a flag, as otherwise an optimized regexp can behave differently than original one, which is dangerous to use as an ESLint plugin or a transpiler.
The text was updated successfully, but these errors were encountered: