Skip to content

Commit 88f537b

Browse files
committed
Issue in setting accessor in PathTypeHandlerWithAttr
When the property is deleted (say when we are in SimpleTypeHandler) and then later if we create an accessor on the same property we have converted the type handler to PathTypeHandlerWithAttr. But during setting the accessor on that slot we haven't removed the is_deleted attribute. So when we try to get the property - we don't get that from the PathTypeHandlerWithAttr handler. Fixed that by removing that attribute when we do SetAccessor.
1 parent 6b98ef8 commit 88f537b

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/Runtime/Types/PathTypeHandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,7 @@ namespace Js
11961196
}
11971197
}
11981198

1199-
SetAttributesHelper(instance, propertyId, propertyIndex, attributes, (ObjectSlotAttributes)(attr | ObjectSlotAttr_Accessor));
1199+
SetAttributesHelper(instance, propertyId, propertyIndex, attributes, (ObjectSlotAttributes)((attr & ~ObjectSlotAttr_Deleted) | ObjectSlotAttr_Accessor));
12001200
// SetAttributesHelper can convert to dictionary in corner cases, e.g., if we haven't got a full path from the root. Remove this check when that's fixed.
12011201
if (!instance->GetTypeHandler()->IsPathTypeHandler())
12021202
{

test/Bugs/bug_6271.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
function testReconfigureAsAccessorProperty(f) {
7+
var length = 2;
8+
Object.defineProperty(f, 'length', {
9+
get: function () {
10+
return length;
11+
},
12+
set: function (v) {
13+
length = v;
14+
}
15+
});
16+
}
17+
(function testSetOnInstance() {
18+
function f() {}
19+
delete f.length;
20+
testReconfigureAsAccessorProperty(f);
21+
Object.defineProperty(Function.prototype, 'length', {
22+
writable: true
23+
});
24+
f.length = 123;
25+
f.length == 123 ? print("Pass") : print('fail');
26+
})();
27+

test/Bugs/rlexe.xml

+5
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@
623623
<files>bug_6277.js</files>
624624
</default>
625625
</test>
626+
<test>
627+
<default>
628+
<files>bug_6271.js</files>
629+
</default>
630+
</test>
626631
<test>
627632
<default>
628633
<files>bug_OS23102586.js</files>

0 commit comments

Comments
 (0)