yodaos-project / ShadowNode

Use Node.js in your end devices(QQ: 796448809)
https://yodaos-project.github.io/ShadowNode/
Other
588 stars 46 forks source link

`hasOwnProperty` throws an exception when the type of key is `Symbol` #573

Open jacobbubu opened 4 years ago

jacobbubu commented 4 years ago
var foo = Symbol("foo");
console.log({}.hasOwnProperty(foo));
TypeError: Cannot convert a Symbol value to a string.
    at undefined (/Users/rongshen/tmp/babel-pack/src/index.js:1:1)
    at undefined (/Users/rongshen/github/ShadowNode/src/js/module.js.wrapped:275:36)
    at undefined (/Users/rongshen/github/ShadowNode/src/js/module.js.wrapped:218:23)
    at undefined (/Users/rongshen/github/ShadowNode/src/js/module.js.wrapped:311:26)
    at undefined (/Users/rongshen/github/ShadowNode/src/js/iotjs.js.wrapped:18:2)
    at undefined (/Users/rongshen/github/ShadowNode/src/js/iotjs.js.wrapped:1:1)

That woks in Node.JS.

Txiaozhe commented 4 years ago

This is the characteristic of JerryScript~

yorkie commented 4 years ago

The spec allows the symbol to be valid property key at https://tc39.es/ecma262/#sec-ispropertykey, the ShadowNode's builtin JerryScript accepts the string only, and it's still not getting fixed on latest JerryScript :(