-
(**edit: ** oh, I think I misunderstood your last suggestion about setting
b
, never mind 😊)Sure, I'll try that 🙂.
I've updated the test code to:
let b; function onInit() { setTimeout(() => { b = 1; }, 5000); }
The dump now first produces:
>dump() var b = undefined; function onInit() { setTimeout(() => { b = 1; }, 5000); } setTimeout(function (undefined) {b = 1;}, 1840.55); // 1 pinMode(D0, "input_pullup", true); pinMode(D12, "input_pullup", true); pinMode(D13, "input_pullup", true); pinMode(D14, "input_pullup", true); pinMode(D15, "input_pullup", true); pinMode(D18, "input_pullup", true); pinMode(D19, "input_pullup", true); pinMode(D21, "input_pullup", true); pinMode(D22, "input_pullup", true); pinMode(D25, "input_pullup", true); pinMode(D26, "input_pullup", true); pinMode(D27, "input_pullup", true); pinMode(D34, "input_pullup", true); pinMode(D35, "input_pullup", true); pinMode(D36, "input_pullup", true); pinMode(D37, "input_pullup", true); pinMode(D38, "input_pullup", true); pinMode(D39, "input_pullup", true); // Code saved with E.setBootCode let b; function onInit() { setTimeout(() => { b = 1; }, 5000); }=undefined
And after > 5 s
>dump() var b = 1; function onInit() { setTimeout(() => { b = 1; }, 5000); } pinMode(D0, "input_pullup", true); pinMode(D12, "input_pullup", true); pinMode(D13, "input_pullup", true); pinMode(D14, "input_pullup", true); pinMode(D15, "input_pullup", true); pinMode(D18, "input_pullup", true); pinMode(D19, "input_pullup", true); pinMode(D21, "input_pullup", true); pinMode(D22, "input_pullup", true); pinMode(D25, "input_pullup", true); pinMode(D26, "input_pullup", true); pinMode(D27, "input_pullup", true); pinMode(D34, "input_pullup", true); pinMode(D35, "input_pullup", true); pinMode(D36, "input_pullup", true); pinMode(D37, "input_pullup", true); pinMode(D38, "input_pullup", true); pinMode(D39, "input_pullup", true); // Code saved with E.setBootCode let b; function onInit() { setTimeout(() => { b = 1; }, 5000); }=undefined
I think I'm at a point where I really need to now what
dump()
is supposed to do exactly 🤔. Because if its description is something like "Will return your code transformed to es2015, your default pin configuration, and a copy of your original code", the output makes sense.
I've read https://www.espruino.com/Reference#l__global_dump of course, but I don't know what is meant by "current interpreter state", or more specifically what the interpreter is supposed to hold exactly 🙂.I think I need @Gordon, just to see if we're on to something, or if the dump() output is as expected.
After reading MDN, I don't believe two instances should exist as they are in the same block (Global) scope.
and thanks for clarifying it wasn't a task performed by your actions.
This issue probably crept in when ECMA6 statements started to get added in, circa 2019.
Should you have some time/desire it would be interesting to do some tests (which you did at least one) setting 'b' to some value, perform the dump() along with just typing
b
at the command line and see if susequent updates can/can-not corrupt it's value. I'm pretty sure it will, as there can be only one instance by definition. This was one of several observations I made and documented (see #45 post for links) six months ago. Interesting that no one else observed this anomaly until now.