Comments (4)
Thanks for tracking this down!
It seems that a finally block are only executed if the try/catch block had no control flow statements in them.
Is it any control flow statements, like if/whole/do/for/etc, or literally just return
that's not working?
from espruino.
@gfwilliams It seems that return
, break
and continue
are the problematic statements. I ran tests in the Web IDE using the Bangle.js emulator.
These are examples where finally
is not executed:
// Not reaching finally block
(() => {
try {
console.log("testing return...");
return;
} finally {
console.log("return success");
}
})();
(() => {
do {
try {
console.log("testing break...");
break;
} finally {
console.log("break success");
}
} while (false);
})();
(() => {
do {
try {
console.log("testing continue...");
continue;
} finally {
console.log("continue success");
}
} while (false);
})();
And these are cases where it is executed correctly
// Reaching finally block
(() => {
try {
console.log("testing if...");
let someVariable = 0;
if (true) {
someVariable = 1;
}
if (false) {
someVariable = 0;
}
} finally {
console.log("if success");
}
})();
(() => {
try {
console.log("testing while...");
let i = 0;
while (i < 1) {
i++;
}
} finally {
console.log("while success");
}
})();
(() => {
try {
console.log("testing do-while...");
let i = 0;
do {
i++;
} while (i < 2);
} finally {
console.log("do-while success");
}
})();
(() => {
try {
console.log("testing for...");
for (let i = 0; i < 1; i++) {
}
} finally {
console.log("for success");
}
})();
(() => {
try {
console.log("testing throw...");
throw new Error();
} catch (e) {
throw new Error();
} finally {
console.log("throw success");
}
})();
I've confirmed all of them are executed expected in chrome
from espruino.
Thanks! I'm pretty sure that's now fixed.
from espruino.
@gfwilliams thanks! confirmed to be working here as well :)
from espruino.
Related Issues (20)
- JIT: Creating objects which reference a parameter value does not work
- Graphics.wrapString cuts up images in strings HOT 1
- Build LINUX board on Mac Os X Intel HOT 5
- Storage.writeJSON and Storage.readJSON are incompatible when numeric keys are present HOT 3
- Global error capture HOT 6
- wifi.stopAP() does not work, AP is still up.... HOT 3
- Wifi.connect(ssid, options, callback) does not handle callback HOT 2
- Multiple uploads of code with wifi command can cause " New interpreter error" HOT 1
- Debugger feature: add backtrace command HOT 2
- E.getPowerUsage to estimate power consumption HOT 2
- BLE/NRF and esp32_gatts_func.c HOT 1
- Promise handling rewrite break BLE device use HOT 3
- ESP32_IDF4 (ESP32C3) support HOT 4
- Any plans to switch to python3? HOT 5
- `Object.defineProperty(<function>, ...)` HOT 1
- `Object.clone()` returning function HOT 2
- Using different pins for neopixel on ESP32 does not work correct HOT 1
- Loss of errors when executing require() HOT 4
- banglejs_iflash build: error running `.bootcde`, compacting corrupts `.boot0` and deletes most files HOT 3
- Static fields in classes HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from espruino.