Acknowledged
CIQQA-3092

bug: Boolean constant can't be appended to string

class {
    (:debug) const IS_RELEASE = false;
    (:release) const IS_RELEASE = true;

    function foo() as Void {
        var s1 = "release: " + IS_RELEASE; // The operator '+' is undefined for the argument type '$.Toybox.Lang.Boolean'.
        var b = IS_RELEASE;
        var s2 = "release: " + b; // this is OK
    }
}
In the above code you can see that a constant boolean is treated differently than a variable with boolean value.
SDK 8.1.0, fr630, strict typechecker
Parents
  • This also suggests to me that the optimizer is unable (or unwilling) to optimize the following code by replacing b with its value:

    var b = IS_RELEASE;
    var s2 = "release: " + b;

    i.e. If the optimizer changed the above code to something like "var s2 = "release: " + IS_RELEASE;", then it seems that it would trigger the same error as the other lines, but it doesn't.

Comment
  • This also suggests to me that the optimizer is unable (or unwilling) to optimize the following code by replacing b with its value:

    var b = IS_RELEASE;
    var s2 = "release: " + b;

    i.e. If the optimizer changed the above code to something like "var s2 = "release: " + IS_RELEASE;", then it seems that it would trigger the same error as the other lines, but it doesn't.

Children