askql icon indicating copy to clipboard operation
askql copied to clipboard

Calling a method named the same as an Object.prototype method results in a 'Cannot call null' error

Open czerwinskilukasz1 opened this issue 4 years ago • 1 comments

Examples:

3:toString
3:toString()

'a':__defineGetter__
'a':__defineGetter__()

and other from Object.prototype

return in an error: Uncaught Error: Cannot call null

image

czerwinskilukasz1 avatar Jun 25 '20 20:06 czerwinskilukasz1

Following our conversation in https://github.com/xFAANG/askql/issues/69:

Me:

I didn't know we allow accessing Javascript properties straight from AskVM. Is it safe?

mhagmajer:

@czerwinskilukasz1 we use object as the data structure for resources map. When you create an object in JavaScript using {} it derives all properties of Object.prototype. To avoid that you can use Object.create(null) but people really do as this is less convenient API

czerwinskilukasz1 avatar Jun 25 '20 20:06 czerwinskilukasz1