Acknowledged

Maybe a bug in Toybox.Weather in SDK4.2.1 or higher

I found a weird behavior in Toybox.Weather module.

According to the instruction below, return type of Dailyforecast.highTemperature is Time.Moment.

https://developer.garmin.com/connect-iq/api-docs/Toybox/Weather/DailyForecast.html

On the other hand, lowTemperature is Lang.Number.

In the program, highTemperature works as Time.Moment and

it causes an error for my app.

This occurs from SDK4.2.1 and higer.

I mean highTemperature is regrded as Lang.Number in SDK4.1.7 or lower.

Is this a bug?

Parents
  • Hi Jim and SHN!

    I appriciate both of you for replying, so much!

    I made a new project and just added below for a test.

            var w =  Weather.getDailyForecast();
            if (w.size() >= 2) {
                var temperature = w[1].lowTemperature + 1;
                //var temperature = w[1].highTemperature + 1;
                //var temperature = w[1].highTemperature.toString().toNumber() + 1;
                System.println(temperature);
            }
     
    Then, I tried to run the commented out lines one by one.
    1st attempt,  var temperature = w[1].lowTemperature + 1; is OK
    2nd attempt, var temperature = w[1].highTemperature + 1;, here I had some errors below.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:33,12: Cannot perform operation 'add' on types 'PolyType<Null or $.Toybox.Time.Moment>' and '$.Toybox.Lang.Number'.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:35,12: Value may not be initialized.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:35,12: Invalid 'Uninitialized' passed as parameter 1 of type 'PolyType<Null or $.Toybox.Lang.Object>'.
    3rd attempt, var temperature = w[1].highTemperature.toString().toNumber() + 1; is OK again.
    I think w[1].highTemperature is regarded as "types 'PolyType<Null or $.Toybox.Time.Moment>'" and it matches the information in the document...
    Excuse me for bothering you again but I appreciate if you have any idea.
    Thanks!
Comment
  • Hi Jim and SHN!

    I appriciate both of you for replying, so much!

    I made a new project and just added below for a test.

            var w =  Weather.getDailyForecast();
            if (w.size() >= 2) {
                var temperature = w[1].lowTemperature + 1;
                //var temperature = w[1].highTemperature + 1;
                //var temperature = w[1].highTemperature.toString().toNumber() + 1;
                System.println(temperature);
            }
     
    Then, I tried to run the commented out lines one by one.
    1st attempt,  var temperature = w[1].lowTemperature + 1; is OK
    2nd attempt, var temperature = w[1].highTemperature + 1;, here I had some errors below.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:33,12: Cannot perform operation 'add' on types 'PolyType<Null or $.Toybox.Time.Moment>' and '$.Toybox.Lang.Number'.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:35,12: Value may not be initialized.
    ERROR: vivoactive4: C:\EclipseIQconnect\TestPJ00\TestPJ00\source\TestPJ00View.mc:35,12: Invalid 'Uninitialized' passed as parameter 1 of type 'PolyType<Null or $.Toybox.Lang.Object>'.
    3rd attempt, var temperature = w[1].highTemperature.toString().toNumber() + 1; is OK again.
    I think w[1].highTemperature is regarded as "types 'PolyType<Null or $.Toybox.Time.Moment>'" and it matches the information in the document...
    Excuse me for bothering you again but I appreciate if you have any idea.
    Thanks!
Children