-
Notifications
You must be signed in to change notification settings - Fork 750
Lacking support for ES6 block scoping #575
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Bug Description
There is a bug in Object.defineProperty that always returns the last set property regardless of what property is being accessed.
- I have run
gradle cleanand confirmed this bug does not occur with JSC
Hermes version: 0.8.1
React Native version: n/a
OS version: n/a
Platform: arm64-v8a, x86_64
Steps To Reproduce
Run the following code example with hermes-engine-cli and node, and compare the output:
const target = {
a: "a",
b: "b",
c: "c",
};
const copy = {};
let keys = "";
for (const prop in target) {
keys += " " + prop;
Object.defineProperty(copy, prop, {
get: () => target[prop],
enumerable: true,
});
}
// I don't know how to output to console so I'm just using a throw 😛
throw new Error(`copy: a = ${copy.a}, b = ${copy.b}, c = ${copy.c} (keys:${keys})`);
Output:
Uncaught Error: copy: a = c, b = c, c = c (keys: a b c)
at global (repro.js:18:16)
The Expected Behavior
This should throw copy: a = a, b = b, c = c, as Node does:
Error: copy: a = a, b = b, c = c (keys: a b c)
at Object.<anonymous> (/~/repro.js:18:7)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request