Skip to content

Add regular RegExp Unicode property escape tests#1014

Merged
leobalter merged 1 commit intotc39:masterfrom
mathiasbynens:early-errors-property-escapes
May 1, 2017
Merged

Add regular RegExp Unicode property escape tests#1014
leobalter merged 1 commit intotc39:masterfrom
mathiasbynens:early-errors-property-escapes

Conversation

@mathiasbynens
Copy link
Copy Markdown
Member

@leobalter leobalter merged commit d5e1150 into tc39:master May 1, 2017

/[\p{Hex}]/u;
assert(
/[\p{Hex}-\uFFFF]/u.test('-'),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regular expression should result in a SyntaxError, because of step 1 in https://tc39.github.io/ecma262/#sec-runtime-semantics-characterrange-abstract-operation.

Copy link
Copy Markdown
Member Author

@mathiasbynens mathiasbynens May 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anba Your commit in tc39/ecma262@d898df2 replaced "If A does not contain exactly one character or B does not contain exactly one character, throw a SyntaxError exception." with "Assert: A and B each contain exactly one character.". Where is the error thrown now?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now an early syntax error.

https://tc39.github.io/ecma262/#sec-patterns-static-semantics-early-errors

NonemptyClassRanges :: ClassAtom - ClassAtomClassRanges

  • It is a Syntax Error if IsCharacterClass of the first ClassAtom is true or IsCharacterClass of the second ClassAtom is true.

A similar restriction is in place for " NonemptyClassRangesNoDash :: ClassAtomNoDash - ClassAtomClassRanges".

Annex B modifies the early syntax error for non-Unicode patterns in https://tc39.github.io/ecma262/#sec-patterns-static-semantics-early-errors-annexb.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for confirming. I'll update this test accordingly and upstream it to Test262.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants