Acknowledged
CIQQA-3111

bug: compiler throws away module from function call + WatchUi has :showToast should be false

import Toybox.Lang;
import Toybox.Graphics;
import Toybox.WatchUi;

function showToast(msg as String or ResourceId, options as { :icon as BitmapResource or BitmapReference or ResourceId } or Null) as Void {
    if (WatchUi has :showToast) {
        WatchUi.showToast(msg, options);
    }
}

Error: Stack Overflow Error Details: Failed invoking <symbol> Stack:
- showToast() at Utils.mc:5 0x10000d92
- showToast() at Utils.mc:7 0x10000db7
...

I know some will tell me I shouldn't use the same function name that already exists, which I might do as a workaround, this still is a huge bug in the compiler.

What's more interesting is that it looks like there's another bug hiding here: vivoactive3 doesn't even have WatchUi.showToast, so the whole block should have been skipped altogether...

SDK 8.1.1, simulator, vivoactive3

Parents
  • I can recreate both problems on Windows or Mac, for a simulated vivoactive3.

    The incorrect has check resolution bug only happens when optimization is enabled and --disable-api-has-check-removal is specified.

    With -O 1/2/3 and --disable-api-has-check-removal specified, the has check bug occurs

    With -O 1/2/3 and --disable-api-has-check-removal not specified, the has check bug does not occur

    Perhaps surprisingly, for -O 0, the has check bug does not occur. (ofc in this case it makes no difference whether --disable-api-has-check-removal is specified or not)

Comment
  • I can recreate both problems on Windows or Mac, for a simulated vivoactive3.

    The incorrect has check resolution bug only happens when optimization is enabled and --disable-api-has-check-removal is specified.

    With -O 1/2/3 and --disable-api-has-check-removal specified, the has check bug occurs

    With -O 1/2/3 and --disable-api-has-check-removal not specified, the has check bug does not occur

    Perhaps surprisingly, for -O 0, the has check bug does not occur. (ofc in this case it makes no difference whether --disable-api-has-check-removal is specified or not)

Children
No Data