Skip to content

RegExp.prototype.lastIndex cannot be set properly via Object.defineProperty #6512

Open
@QuXing9

Description

@QuXing9

Description

When using the function RegExp() to create a RegExp object. The object's lastIndex property should be 0 and the property descriptor writable should be true. But when i use the function Object.defineProperty to redefine the property lastIndex . Chakra failed to change its value while all other engines such as V8, SpiderMonkey, and JavascriptCore changed successfully. Is this a normal behavior of Chakra?

Version

chakra 1.11.22

Run Command

chakra-1_11_22/bin/ch testcase.js

Testcase

var regexp5 = new RegExp(/abc/);
print(regexp5.lastIndex);

Object.defineProperty(regexp5, "lastIndex", {
	value: "\w?\B",
	writable: false
});
print(regexp5.lastIndex);

Output

0
0

Expected output

0
w?B

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions