Bug 151348

Summary: Nonstandard RegExp own properties do not observe invariability of nonwritable, nonconfigurable property
Product: WebKit Reporter: Claude Pache <claude.pache>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: ashvayka, ggaren, msaboff
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

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 ***