Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Details:
- > I doubt, because even this can reproduce it:
- > var x = foo <= 0;
- If that's the case, then why is it necessary to press play to trigger the crash in the first place?
- What's the exact error/exception that you are seeing?
- If even "var x = foo <= 0;" causes an exception, then it seems that only possible way an error would be triggered or an exception would be thrown if foo is non-numeric (e.g. null or String).
- Anyway, I was able to recreate the problem too.
- My observations (in the sim, with fr955):
- - with the original formulation of the code (with the double ternary) in SDK 8.0.0-beta, the code indeed crashes when activity data is simulated, with the following error:
- Error: Unexpected Type Error
- Details: Failed invoking <symbol>
- - When I switched back to SDK 7.4.3, the original code indeed did not crash when activity data is simulated
- - with the original code, it's also possible to crash the code by selecting Reset All App Data (in SDK 8.0.0-beta). This kinda makes sense, as foo may actually be null in this case (and null can't be compared to 0 using <=). Or at least I was able to do so while the sim needed access to my Connect IQ credentials (as it was unable to grab them from my MacOS keychain). Once I provided those, I was unable to get the code to crash by selecting Reset All App Data. So it seems this might be a bug / loophole in the sim where sometimes Reset All App Data will cause properties with a default value to be returned as null
- - the second formulation (var x = foo <= 0;) does not crash when activity data is simulated (how could that possibly make it crash?). I assume it would've crashed if the sim was in the state where Reset All Data would make foo null, if I pressed Reset All Data. As I was no longer in that state, I was unable to make this code crash
- I rewrote the original code as if-else statements, based on my understanding of the original logic, and indeed, it no longer crashes on SDK 8.0.0-beta.
- if (foo <= 0) {
- heartRate = info.currentHeartRate;
- } else {
- if (bar != null) {
- heartRate = bar.average;
- } else {
- heartRate = null;
- }
- }
- This suggests that when the code does crash due to triggering activity data, somehow the fact that info.currentHeartRate is non-zero/non-null leads bar.average to be evaluated, which crashes because bar is null
Advertisement
Add Comment
Please, Sign In to add comment