-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Invalid regexp property escape should throw an __early__ SyntaxError. #918
Comments
Starting with ES6 this is now covered by the first rule of 12.2.8.1. However, that rule should probably be elaborated to parse using an appropiate U value based upon whether or not u is in the FlagText part. |
@allenwb Would you consider that the same issue or a separate issue? |
12.2.8.1 only covers parsing the RegExp literal using the grammar in 21.2.1. But parsing it with 21.2.1's grammar does not include executing the runtime checks, like the one in 21.2.2.15.1 Runtime Semantics: CharacterRange, step 1. One example for a RegExp which per the current spec, may or may not throw a SyntaxError at runtime, was given in my original comment: ES5 had this covered (more or less, probably depending on how you interpret it), in ch16:
But this early error restriction was dropped in ES6. |
The intent was that the early error rule in 12.2.8.1 subsumed the ES5 Chapter 16 rule about RegExp early errors. However, I guess that wasn't made clear in 12.2.8.1. The algorithmic syntax error detection in the RegExp evaluation algorithms really shouldn't be there. They are a carry over from Edition 3 where the spec. which did not use separate static semantic clauses listing syntax-derived early errors (and hence the need for the Ch 16 rule). What I should have done in ES6 is to factor all of those syntax error checks out of the RegExp evaluation algorithms and restated them as early error rules in 21.2.1.1. Not doing so was an oversight on my part, or perhaps I ran out of time. The purpose of placing these errors into 21.2.1.1 (and with the early error static semantic errors, in general) is to clearly state the errors that identify malformed ES code that can be detected and reported independently of an run-time context or values. The goal is to eliminate implementation variations in when such errors are reported. |
As verified in Test262, I'd like to confirm a mal formed property escape in a regexp should throw an Early Error.
I can't write a patch for this right now, but I want to keep track of this issue.
From @anba comments:
The text was updated successfully, but these errors were encountered: