Closed YiWen-y closed 3 years ago
The source and flags getters both throw if the receiver is not a regex, which covers your a
.
what happens with b
if you comment out a
?
When executing the above test case, Chakra throws TypeError: RegExp.prototype.toString:'this' is not a RegExp object
in line 4 (b). After commenting out a, executing this code still throws TypeError. I also executed this test cases on other engines (such as v8, spider Monkey, JavascriptCore, etc.), and they all executed normally without causing any errors.
Thank you for the report!
The correct implementation is behind the flag ES6RegExPrototypeProperties
if you run the test with -ES6RegExPrototypeProperties
to enable the flag it should have the correct result.
Enabling that flag is part of #6390 I'm afraid ChakraCore's regexp engine is a weak point of sorts.
Version
chakra-9e2f198
Test case
Execution steps
Output
Expected behavior
Description
I checked the ES standard and found that the standard only stipulates that the
this
value ofRegExp.prototype.toString
must be an object, but chakra requiresthis
value to be a regular object. May I know what is the reason?According to ES2019 standard, the steps of
RegExp.prototype.toString
are as follows.The ECMAScript standard reference is as follow:
http://www.ecma-international.org/ecma-262/10.0/index.html#sec-regexp.prototype.tostring