Given this code (this is the whole file. No imports/using etc):
const FONT = $.Toybox.Graphics.FONT_XTINY;
The type checker is happy (even at Strict), but I get:
Error: Circular Dependency Error Details: Failed invoking <symbol> Stack: - <init>() at bug.mc:1 0x100010b4 - Native code0x80000000
when I try to launch the app.
If I drop the '$'
const FONT = Toybox.Graphics.FONT_XTINY;
I get:
Error: Unexpected Type Error Details: Failed invoking <symbol> Stack: - <init>() at bug.mc:1 0x100010b4 - Native code0x80000000
If instead I do:
function getFont() as Toybox.Graphics.FontDefinition { return $.Toybox.Graphics.FONT_XTINY; }
Then I can call getFont() and it works. It also works if I drop the '$'.
So the fully qualified symbol seems to be correct, even absent any imports, but it can't be used as an initializer. I'm guessing there's some order of initialization thing going on here, and maybe its not fixable... but if thats the case, the type checker should really be made aware of the situation so that such code simply isn't allowed.
On the other hand, if I add "import Toybox.Graphics", and change the code to "const FONT = Graphics.FONT_XTINY;", then it works as expected.
After some more experimenting, I can get similar issues without using Toybox entities at all:
import Toybox.Lang; // just for "v as Number" const KONST = 1; var v as Number = $.KONST;
This crashes with the "Circular dependency" error. But if I drop the "$" in v's initializer, the code works...