From 9b34a8ccebdfd937723bfa97f1f03b83d399046f Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 16 Dec 2023 02:17:14 +0000 Subject: [PATCH] TODO --- TODO.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/TODO.md b/TODO.md index cfd2fcf1..5df7ec83 100644 --- a/TODO.md +++ b/TODO.md @@ -17,3 +17,23 @@ with (obj) { module.exports = () => { x = 2; }; } ``` + +Could output a 2nd `with ()` which catches const violations: + +```js +x => with$0 => { + with ({get x() { return x; }, set x(v) { const x = 0; x = 0; }}) with (with$0) return () => { x = 2; }; +} +``` + +Or for a silent const, a setter which does nothing: + +```js +x => with$0 => { + with ({get x() { return x; }, set x(v) {}}) with (with$0) return () => { x = 2; }; +} +``` + +If multiple `with` blocks, would need to put the "protector" `with` outside the last `with`. + +This same technique could be used to prevent mutating consts in `eval()`.