Under Review

bug: System.println and static inlined strings in the simulator cause the wrong string to be used

The following code ran on any device with at least CIQ 3.4.0 that supports toasts (i.e: fr955) in the simulator (either 7.4.3 or 8.0.0-Beta) will incorrectly display "other" instead of the expected "toast".

System.println("toast");
if (WatchUi has :showToast) {
    WatchUi.showToast("toast", null);
}
System.println("other");

I'm not 100% sure whether the bug is in println or maybe showToast or how the simulator implements some string functions or if it's a bug in the compiler, but the above few lines clearly reproduce it. I created a new Watch App with the Monkey C extension, and put the above code somewhere.

Note that the text logged is correct, only in the toast it's incorrect.

Parents
  • I did find one case where showToast() does display the correct text. If you pass in a string variable as the 1st arg (as opposed to a string literal or a resource ID), the correct text is displayed in the simulator.

    In the simulator:

    // 1) this works
    var x = "hello";
    WatchUi.showToast(x, null);

    // 2) this does not work
    WatchUi.showToast("hello", null);
    // 3) this does not work
    var x = Rez.Strings.AppName;
    WatchUi.showToast(x, null);

    // 4) this does not work
    WatchUi.showToast(Rez.Strings.AppName, null);

    The above results were obtained in the simulator.

    On a real device (fr955), I only tried 4) (passing in a literal resource ID), and it worked properly.

Comment
  • I did find one case where showToast() does display the correct text. If you pass in a string variable as the 1st arg (as opposed to a string literal or a resource ID), the correct text is displayed in the simulator.

    In the simulator:

    // 1) this works
    var x = "hello";
    WatchUi.showToast(x, null);

    // 2) this does not work
    WatchUi.showToast("hello", null);
    // 3) this does not work
    var x = Rez.Strings.AppName;
    WatchUi.showToast(x, null);

    // 4) this does not work
    WatchUi.showToast(Rez.Strings.AppName, null);

    The above results were obtained in the simulator.

    On a real device (fr955), I only tried 4) (passing in a literal resource ID), and it worked properly.

Children
No Data