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 upInvalid regexp property escape should throw an __early__ SyntaxError. #918
Comments
leobalter
added
the
needs consensus
label
May 17, 2017
leobalter
referenced this issue
May 17, 2017
Merged
Fix test involving a Unicode property escape in a character class range #1034
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Sep 13, 2017
Member
Somehow this was dropped in ES6 which leads to at least one contradiction, in https://tc39.github.io/ecma262/#sec-pattern, we've got:
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.
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@allenwb Would you consider that the same issue or a separate issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Sep 13, 2017
Contributor
Somehow this was dropped in ES6 which leads to at least one contradiction, in https://tc39.github.io/ecma262/#sec-pattern, we've got:
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.
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: /a|(?![\d-\d])/u.
ES5 had this covered (more or less, probably depending on how you interpret it), in ch16:
Errors in regular expression literals that are not implementation-defined syntax extensions.
But this early error restriction was dropped in ES6.
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
allenwb
Sep 13, 2017
Member
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.
|
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. |
leobalter commentedMay 17, 2017
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: