-
Notifications
You must be signed in to change notification settings - Fork 482
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
CharacterRange abstract operation tests should be phase: runtime and not phase: early #1193
Comments
The same issue now also manifests in built-ins/RegExp/property-escapes/character-class.js (as of commit e44d737). The abstract operation CharacterRange should throw |
Thanks for the raising these issues! This topic is not really in my best field of experience, I might need some feedback from @anba, @jugglinmike, or @mathiasbynens here. In any case, PRs are most welcome! |
Spec PR to change RegExps per web-reality, i.e. throw when invalid ranges are present, is up at tc39/ecma262#984 |
@anba, yes, moving the |
OK, the spec has been changed upstream, so I am closing this issue. |
The Early Errors rule for regular expression literals states that the literals must be parsed using the
Pattern
goal symbol of the regular expression grammar. This might trigger earlySyntaxError
s when the regular expression in the literal is malformed. However, there are some "malformed" regular expressions which still pass the grammar and its early errors conditions, e.g./[\s-\d]/u
, where the bounds of a character range are character sets, not single characters. Such expressions also lead toSyntaxError
s, but only during the evaluation of the regular expression literal, when interpreting the pattern as aRegExpMatcher
using the Pattern Semantics.Therefore, I believe the tests in the following files to be incorrect as of their current state:
The phase of the
SyntaxError
should beruntime
instead ofearly
and therefore they shouldn't be prefixed with the throw statements. The RegExp validation is performed in Runtime Semantics: Character Range and not in Static Semantics.NB: In ES5.1,
SyntaxError
s thrown by the runtime semantics of constructing aRegExp
object actually did cause early errors, but this behaviour disappeared from the spec in ES6.NB2: These tests contradict the test built-ins/RegExp/property-escapes/character-class.js), in which the regular expression literal
/[\p{Hex}-\uFFFF]/u
is expected to throw aSyntaxError
at runtime.The text was updated successfully, but these errors were encountered: