Show Runtime Values vs. defineProperty on globals
Opened this issue · 1 comments
Hello! This is very minor and is only an issue with Show Runtime Values - Experimental checked, but I thought it would be worth reporting, mostly in case others come across it.
The conditions I've encountered may not be everything, but are fairly specific:
- Show Runtime Values - Experimental is checked.
Object.defineProperty
modifies a global value (e.g. Array.prototype)defineProperty
uses a getter, setter, or explicitly setswritable: false
.- Any valid syntax follows the
defineProperty
call, even if it would throw an error.
When using defineProperty
on a global like Array.prototype
I encounter TypeError: Cannot redefine property:
and execution stops, but only if there is code following the defineProperty call:
// Code before executes as expected and displays output
a = 2;
Object.defineProperty(Array.prototype, 'not', {
get() { return false; },
});
// TypeError: Cannot redefine property: not
// happens and execution stops if any code is after define
// with valid syntax, even if it would throw an error
b;
The error does not happen with a local variable:
const a = { is: true };
// No error when defineProperty is on a local variable
Object.defineProperty(a, 'not', {
get() { return !this.is; },
});
a.is; // true
a.not; // false
And an image demonstrating the error for completeness:
I'm not sure if this is a worth further research as it works properly when you turn off Show Runtime Values.
Thank you so much for making this amazing tool. I love it and regularly recommend it to others.