Under Review
over 1 year ago

Sdk 4.1.7 constant folds floats + strings incorrectly

Given this code:

        var k = 1.0;
        var x = 1.0 + "foo";
        var y = k + "foo";
        System.println(x);
        System.println(y);

The output is:

1.0foo
1.000000foo
with sdk 4.1.7, and -O1 or -O2. With -O0 (or with 4.1.5 and earlier) it prints:
1.000000foo
1.000000foo
In other words, when the addition is performed at runtime, we get 1.000000foo. When its folded at compile time, we get 1.0foo.