Bug 151348 - Nonstandard RegExp own properties do not observe invariability of nonwritable, nonconfigurable property
Summary: Nonstandard RegExp own properties do not observe invariability of nonwritable...
Status: RESOLVED DUPLICATE of bug 220233
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-17 05:39 PST by Claude Pache
Modified: 2021-07-23 16:52 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Claude Pache 2015-11-17 05:39:49 PST
Testcase:

> Object.getOwnPropertyDescriptor(RegExp, 'lastMatch') 
< {value: "", writable: false, enumerable: true, configurable: false} 

> /a/.exec('a')

> Object.getOwnPropertyDescriptor(RegExp, 'lastMatch')
< {value: "a", writable: false, enumerable: true, configurable: false} 


The value of the property changes even when it is marked as nonwritable and nonconfigurable.
This must not be the case; for reference, see:

http://www.ecma-international.org/ecma-262/6.0/#sec-invariants-of-the-essential-internal-methods
paragraph [[GetOwnProperty]] (P), third bullet


The best thing to do, here, is to use an accessor property.
Comment 1 Alexey Shvayka 2021-07-23 16:52:52 PDT
Thank you for detailed report and your effort on https://github.com/tc39/proposal-regexp-legacy-features proposal, Claude!

Legacy RegExp field are being turned into accessors in https://bugs.webkit.org/show_bug.cgi?id=220233.

*** This bug has been marked as a duplicate of bug 220233 ***