Expressions: an expression can't delete a kept layer's fields

This commit is contained in:
tylerjenningsw
2026-10-27 14:04:10 -04:00
parent f4a4d76f2a
commit 0860c7e03d
2 changed files with 7 additions and 4 deletions
+5 -4
View File
@@ -550,12 +550,13 @@ function Layer(c, l) {
delete f.name;
delete f.length;
Object.setPrototypeOf(f, Layer.prototype);
// Kept across evaluations (`__layer`), so an expression can't change which layer it is or leave
// its own fields on it. `__i` and `__s` stay writable: `__info` reads them again in an evaluation
// whose `__S` isn't `__s`, and every evaluation has a new `__S`.
// Kept across evaluations (`__layer`), so an expression can't change which layer it is, delete
// a field or leave its own on it. `__i` and `__s` stay writable: `__info` reads them again in an
// evaluation whose `__S` isn't `__s`, and every evaluation has a new `__S`.
Object.defineProperty(f, '__c', { value: c });
Object.defineProperty(f, '__l', { value: l });
f.__i = null; f.__s = null;
Object.defineProperty(f, '__i', { value: null, writable: true });
Object.defineProperty(f, '__s', { value: null, writable: true });
Object.preventExtensions(f);
return f;
}
+2
View File
@@ -1402,6 +1402,8 @@ fn a_kept_layer_reads_the_project_again() {
assert_close!(f.num("thisLayer.mine === undefined ? 1 : 0", 0.0), 1.0);
let _ = f.ev(f.a, ROT, "var L = thisLayer; L.__c = 'x'; L.__l = 99; L.__i = ['Z', 7]; L.__s = __S; 0", 0.0);
assert_close!(f.num("thisLayer.index * 10 + thisLayer.name.length", 0.0), 21.0);
let _ = f.ev(f.a, ROT, "var L = thisLayer; delete L.__c; delete L.__l; delete L.__i; delete L.__s; 0", 0.0);
assert_close!(f.num("thisLayer.index * 10 + thisLayer.name.length", 0.0), 21.0);
}
mod property_group;