chakra-core / chakra-core/ChakraCore
Spec deviation in RegExp.prototype[@@search]()
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Description
### Version
1.12.0-master
### Flags
-ES6Experimental
### Test code
```js
{
let i = 0;
const proxy = new Proxy({ exec() { return null }, lastIndex: 0 }, {
set(target, p) {
print(`Should not be called`);
print(`Property:`, p, `value:`, value);
i++;
}
})
RegExp.prototype[Symbol.search].call(proxy);
print(i);
}
```
### Excepted result
```js
0
```
### Actual result
```js
Should not be called
Property: lastIndex value: 0
Should not be called
Property: lastIndex value: 0
2
```
### Possible solution
It seems like that JavascriptRegExp::EntrySymbolSearch doesn't perform some checks needed by spec.
https://github.com/chakra-core/ChakraCore/blob/e6c8f78f505cb332538425b7a9309aee217869ef/lib/Runtime/Library/JavascriptRegularExpression.cpp#L812-L819
Possibly i will open a pr after #6610 is merged and it will also fix #5388
Contributor guide
Research direction
Start with lib/Runtime/Library/JavascriptRegularExpression.cpp around lines 812-819, the implementation named in the report, and compare its behavior with the RegExp.prototype[@@search]() specification. Run the supplied Proxy test and verify that the proxy set trap is not called and the output is 0. Check the relationship to issues #6610 and #5388 before deciding the final scope.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, javascript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100