bug: vscode extension warns about possible nulls where it's not possible
Why I get this yellow wave line under the comparsion? I thought this was already fixed long ago (though that might have been in the compiler, not the vsc extension)
This is still not fixed in SDK 8.1.1. Not sure if it's the compiler, the type checker, or what else. strict typecheck is enabled.
function useLocation(info as Activity.Info) as Void {
if (info.currentLocation != null && info.currentLocationAccuracy != null && info.currentLocationAccuracy >= Position.QUALITY_POOR) {
// var pos = (info.currentLocation as Position.Location).toDegrees();
// fetch(pos[0], pos[1], info.altitude);
}
}
ERROR: fr955: Foo.mc:2,8: Attempting to perform operation 'gte' with invalid types 'Null' and '$.Toybox.Lang.Number'.
Needless to say, that even the "(info.currentLocation as Position.Location)" should not be needed. And yeah, I know I'll have to do the same in the condition, but it's so annoying..
To summarize my screenshotted first comment (which was brutally rejected by the forum), I think the problem is in the compiler, not the extension. At least for me, the extension works just fine, in the sense that the warnings/errors in the extension match the warnings/errors in the compiler output.
If that's not what you're seeing, I would guess the problem is that the extension and compiler are out of sync somehow.
But the exact problem stated in the title -- "warns about possible nulls where it's not possible" -- is clearly in the compiler.
I would also say that's very likely that the extension only highlights warnings/errors which are produced by the compiler, by parsing the compiler output.
It would indeed be not-so-great design if all the compiler logic for warnings and errors had to be independently replicated in the extension, which is the only conceivable way that the extension could flag different (compiler) warnings/errors than the compiler itself.