Bug 188789 - Fail to throw TypeError when set a getter-only property in Array.prototype.pop
Summary: Fail to throw TypeError when set a getter-only property in Array.prototype.pop
Status: RESOLVED DUPLICATE of bug 201910
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-21 05:39 PDT by sunlili
Modified: 2020-06-07 06:38 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 sunlili 2018-08-21 05:39:28 PDT
Executing following code :
---------------------------------------------
function foo()
{
    var obj = {};

    Object.prototype.push = Array.prototype.push;
    Object.prototype.pop = Array.prototype.pop;
    var x;
    Object.defineProperty(obj, "length", {get: function() {x = true; return 5;}});
    //call set length while pop,but setter was undefined
    x = false;

    try
    {
        var len = obj.pop();
    }
    catch (e)
    {
        print('caught exception:');
        print(e);
    }
    print(x);
}
foo();

print("BT_FLAG");
-----------------------------------------------------

Output should be :
caught exception:
TypeError: setting getter-only property "length"
true
BT_FLAG

However, output of JavaScriptCore:
true
BT_FLAG



BT_GROUP
2018/8/21
Comment 1 Alexey Shvayka 2020-06-07 06:38:22 PDT
r250275 fixed putLength() with unsuccessful [[Set]], including Array.prototype.pop case.
test262 coverage: https://github.com/tc39/test262/pull/2463.

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