ecma262
ecma262 copied to clipboard
RegExp CharacterRange early error
eshost -s -e '/[\d-\D]/.test("1")'
#### engine262
SyntaxError: Invalid class range
#### javascriptcore, spidermonkey, v8
true
#### xs
SyntaxError: [\d-\D] invalid range
Per spec, it should be an Early Error:
So what are you asking of us here? Are you trying to say this is a web reality issue that we should address with a spec change? If you think it's not relied upon on the web, you should report issues to each of the nonconforming engines.
See Annex B https://tc39.es/ecma262/#sec-patterns-static-semantics-early-errors-annexb for why /[\d-\D]/ doesn't throw a SyntaxError in browsers.
ok... I don't know this is an annex b thing before, I thought spec is wrong
I'm going to re-open this. I don't think the Annex B reference at the top of this section is sufficient for readers. We should add Annex B references in each early error that is augmented by Annex B.
Plan of action from today's editor call is to pursue https://github.com/tc39/ecma262/pull/2445 (or something similar) and eventually merge the Annex B Pattern grammar into the main spec body.