Acknowledged

bug: incorrect ambigoious error message even though correct module is used

SDK 8.1.0, VSC Monkey C extension 1.1.1

import Toybox.Activity;
import Toybox.ActivityRecording;

function foo() as Void {
    var activityType = Properties.getValue("t") as Number;
    var sport = (activityType / 1000) as Activity.Sport;
	var subSport = (activityType % 1000) as Activity.SubSport;
}

gives the incorrect errors:

"owner": "_generated_diagnostic_collection_name_#0",
"severity": 8,
"message": "fr955: 'Sport' is ambiguious and exists in multiple imported modules [$.Toybox.ActivityRecording.Sport, $.Toybox.Activity.Sport].",

and

"owner": "_generated_diagnostic_collection_name_#0",
"severity": 8,
"message": "fr955: 'SubSport' is ambiguious and exists in multiple imported modules [$.Toybox.ActivityRecording.SubSport, $.Toybox.Activity.SubSport].",

  • This bug completely breaks compiling my app in SDK 8.1.0 which was just fine in SDK 7. Combined with the bumped minimum SDK requirements I now can't build anymore for newer devices, even going back to the old SDK because API level 5.1.0 is required).

  • Related bug (which also only happens with import and not using):

    forums.garmin.com/.../1914372

    I have this code, and it doesn't work in SDK 8.1.0:

    The problem is that it thinks that Menu is WatchUi.Menu.

    This causes a compilation error (at least with typecheck set to strict) because I want to assign something that is not an Action to action. This is relatively OK, though IMHO it shouldn't happen.

    It also causes an unexpected behavior when running (of course it needs some changes so it compiles, or disabling typecheck):

    In the switch action will never be equal to Menu (again because an Action is never equal to a module or class.

  • I can reproduce the problem with the code in the OP (although I do have to comment out the line with activityType, and replace it with a hardcoded value, as it's clearly intended to work in the context of the app's AppBase-derived class)

    However, if I change import to using, the problem goes away.

    This suggests that the bug is related to this:

    developer.garmin.com/.../

    Import and Using Statements

    You can bring a module into your scoping level with the import keyword. When you use import it will bring the module suffix and all classes in the module into the type namespace. This allows classes in a module to be accessed without the module suffix, making for easier typing. Function invocations still require the module suffix to be accessed.

    (I still think it's a bug, nonetheless)

  • Also, "ambiguious" in the error message is a typo (should be "ambiguous")