mirror of
https://github.com/facebookarchive/prepack.git
synced 2024-09-11 14:46:37 +03:00
Fix default attributes in joined descriptor (#2390)
Summary: When we create a joined descriptor in an abstract object we need to preserve any attributes of that property that were already there. To do that, we just need to read the first descriptor of the elements since all elements must have the same attributes (or we fatal). Pull Request resolved: https://github.com/facebook/prepack/pull/2390 Differential Revision: D9193129 Pulled By: sebmarkbage fbshipit-source-id: 32db3e88ae65de9a09ff6de72ed5b91ec02cf090
This commit is contained in:
parent
9d02cbc575
commit
be3779315e
@ -410,11 +410,21 @@ export default class AbstractObjectValue extends AbstractValue {
|
|||||||
AbstractValue.reportIntrospectionError(this, P);
|
AbstractValue.reportIntrospectionError(this, P);
|
||||||
throw new FatalError();
|
throw new FatalError();
|
||||||
}
|
}
|
||||||
|
// Extract the first existing descriptor to get its existing attributes as defaults.
|
||||||
|
let firstExistingDesc;
|
||||||
|
for (let cv of elements) {
|
||||||
|
invariant(cv instanceof ObjectValue);
|
||||||
|
firstExistingDesc = cv.$GetOwnProperty(P);
|
||||||
|
if (firstExistingDesc) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
let desc = {
|
let desc = {
|
||||||
value: "value" in Desc ? Desc.value : this.$Realm.intrinsics.undefined,
|
value: "value" in Desc ? Desc.value : this.$Realm.intrinsics.undefined,
|
||||||
writable: "writable" in Desc ? Desc.writable : false,
|
writable: "writable" in Desc ? Desc.writable : firstExistingDesc ? firstExistingDesc.writable : false,
|
||||||
enumerable: "enumerable" in Desc ? Desc.enumerable : false,
|
enumerable: "enumerable" in Desc ? Desc.enumerable : firstExistingDesc ? firstExistingDesc.enumerable : false,
|
||||||
configurable: "configurable" in Desc ? Desc.configurable : false,
|
configurable:
|
||||||
|
"configurable" in Desc ? Desc.configurable : firstExistingDesc ? firstExistingDesc.configurable : false,
|
||||||
};
|
};
|
||||||
let newVal = desc.value;
|
let newVal = desc.value;
|
||||||
if (this.kind === "conditional") {
|
if (this.kind === "conditional") {
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
(function() {
|
||||||
|
let c = global.__abstract ? __abstract("boolean", "(true)") : true;
|
||||||
|
var a = { enumerableProp: 1 };
|
||||||
|
var b = { enumerableProp: 2 };
|
||||||
|
var obj = c ? a : b;
|
||||||
|
Object.defineProperty(obj, "enumerableProp", {
|
||||||
|
value: 3,
|
||||||
|
});
|
||||||
|
global.result = Object.getOwnPropertyDescriptor(a, "enumerableProp");
|
||||||
|
inspect = function() {
|
||||||
|
return global.result;
|
||||||
|
};
|
||||||
|
})();
|
Loading…
Reference in New Issue
Block a user