NeilFraser / JS-Interpreter

A sandboxed JavaScript interpreter in JavaScript.
Apache License 2.0
1.98k stars 353 forks source link

Wrong getter behaviour #184

Closed XmiliaH closed 4 years ago

XmiliaH commented 4 years ago

The following code will run the getter even if it is not a getter:

function func() { return 1; }
var obj = {};
Object.defineProperty(obj, 'getter', {get: func, enumerable: true});
var obj2 = { notAGetter: func };

// 1
alert(obj.getter);

// This will set func.isGetter but not clean it up
Object.apply(null, obj);

// 1
alert(obj2.notAGetter);
// should be [object Function], but isGetter was still set
NeilFraser commented 4 years ago

PR #185 should resolve this issue and explicitly throw in places where we don't support getters and setters. Good catch on this behaviour, I was aware that we don't support getters and setters in certain places, but I wasn't aware that this could cause this kind of weird behaviour.