Acknowledged

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
  • > - compiler sees "toast" string literal in multiple places and puts 1 string constant to the data and uses a reference to it in all places.

    While it's possible that the compiler folds duplicate string literals as you described, I don't think that has anything to do with the problem. I tested differently from you:

    - I tested with a string literal that is different from any other string literal in the app, and the problem occurs

    - I tested with a literal resource ID, and the problem occurs

    - I tested with a resource ID variable, and the problem occurs

    The only way I was able to make it work correctly in the simulator was to use a string variable.

Comment
  • > - compiler sees "toast" string literal in multiple places and puts 1 string constant to the data and uses a reference to it in all places.

    While it's possible that the compiler folds duplicate string literals as you described, I don't think that has anything to do with the problem. I tested differently from you:

    - I tested with a string literal that is different from any other string literal in the app, and the problem occurs

    - I tested with a literal resource ID, and the problem occurs

    - I tested with a resource ID variable, and the problem occurs

    The only way I was able to make it work correctly in the simulator was to use a string variable.

Children
No Data