Under Review

Type checker issues with aliased tuple type

I have my own tuple type defined as:

typedef MGRS as [String, String, Number, Number];

However, I am encountering a lot of pain trying to use it elsewhere in my code because the type checker does not seem to recognize it properly.

When using it as a return type, I get the error:

Object of type '$.NavUtils.Mgrs' does not match return type '$.NavUtils.Mgrs'.

When indexing my tuple, I get the warning:

Cannot determine if container access is using container type.

When using it to define a callback type, I get the error:

Cannot assign value '$.Toybox.Lang.Method(mgrs as $.NavUtils.Mgrs) as Void' to member ':_callback'.

Where _callback is typed exactly as Method(mgrs as $.NavUtils.Mgrs) as Void


The only workaround seems to be to disable the type checker.

  • Hmm as Flocsy sardonically pointed out (there are nicer ways to ask for more code), this is EBCAK. Since I usually like to rely on the compiler to steer me in the right direction though, I would still like to see it identify the real error when I refer to non-existent types.

  • This bug report looks interesting, but I agree that more code might be necessary for anyone else to reproduce your problem.

    I compiled the following snippet (at the global scope) without any warnings or errors at type check level 3, with SDK 7.4.3 and 8.0.0-beta..

    https://pastebin.com/KR6W0X35

  • I write perfect code, but there is a bug in the compiler that gives these error messages: ...

    I spare my perfect code from you, since it's perfect you wouldn't be able to fix it, and I don't care enough to share it, even though it could help others help me or help Garmin understand the cause of the bug...