Acknowledged
CIQQA-3048

bug: documentation of WatchUi.pushView is missing the Returns section

In https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html#pushView-instance_function (SDK 8.1.0) the Returns section is missing.

Or the method declaration is incorrectly states the return type as Boolean:

pushView(view as WatchUi.Views, delegate as WatchUi.InputDelegates or Null, transition as WatchUi.SlideType) as Lang.Boolean

  • Also:

    var x = 42;
    x = WatchUi.pushView(customMenu, new $.BasicCustomDelegate(), WatchUi.SLIDE_UP);
    System.println("pushview returned " + x); // prints null

    I think these tests probably demonstrate that a Void function (which nominally returns no value) actually always returns null in practice, which is not surprising. Same as how functions which nominally don't return a value in js actually return the undefined value. [Contrast with C, where the behaviour is undefined, so you can end up with a "random" value if you manage to call a void function.]

  • If I print out the "return value" of pushView in the simulator, it's actually null, so I think the method declaration is wrong.

    Goes without saying that corresponding type check info is wrong as well. I assume the doc and SDK type check info are genned from the same source.

    This is the kind of thing that could lead to a crash, if someone were to take the null return value of pushView and use it in a context where only boolean is allowed. Ofc why would they do that since there's no obvious meaning to the return value? If pushView fails, it throws an exception.

    e.g. completely artificial example