Acknowledged
over 1 year ago

accessing dictionary data is not consistent

this code (I can't reproduce real error on sim or my watch, so snippet)

var d = {0 => "t"), x;

x = d[1];

on some devices causes Array Out Of Bounds Error but

x = d.get(1);

returns null, as is expected.

Error Name: Array Out Of Bounds Error

Occurrences: 20

First Occurrence: 2023-12-10

Last Occurrence: 2023-12-10

Devices:

Venu® Sq. Music Edition: 4.90

fēnix® 6 Pro / 6 Sapphire / 6 Pro Solar / 6 Pro Dual Power / quatix® 6: 26.00

fēnix® 5 Plus: 19.30

Forerunner® 945: 13.00

Forerunner® 945: 13.00

App Versions: 8.6.0

Languages: chs, eng, ita, jpn, spa

Error Name: Array Out Of Bounds Error

Occurrences: 10

First Occurrence: 2023-12-10

Last Occurrence: 2023-12-10

Devices:

Upcoming Wearable: 15.21

Forerunner® 955 / Solar: 17.26

App Versions: 8.6.0

Languages: eng, jpn

Parents
  • Not to be pedantic, but I assume var d = {0 => "t"), x; contains a typo and should be var d = {0 => "t"}, x;.

    It looks to me that this is not a case where d[1] and d.get(1) are not equivalent, but that you're receiving arrays in those two cases you mention. That makes sense to me since you'll see Array Out of Bounds when attempting d[1] and Symbol Not Found with d.get(1) if it is, in fact, an array. Just as an example, here's a quick check I did:

    var d = {0 => "t"}, e = [1], x, y;
    
    x = d[1];       // null
    y = d.get(1);   // null
    
    x = e[1];       // Array Out of Bounds error
    y = e.get(1);   // Symbol Not Found error

    These represent expected behaviors for Dictionaries (which will return null if the requested key does not exist) and Arrays, respectively.

    We'll have to do some more in-depth investigation to see if we can reproduce when dealing with storage or converting from JSON. I am curious how exactly you're handling the JSON response, so if you have any code snippet you can share that demonstrates how you have this implemented, I'd appreciate it.

Comment
  • Not to be pedantic, but I assume var d = {0 => "t"), x; contains a typo and should be var d = {0 => "t"}, x;.

    It looks to me that this is not a case where d[1] and d.get(1) are not equivalent, but that you're receiving arrays in those two cases you mention. That makes sense to me since you'll see Array Out of Bounds when attempting d[1] and Symbol Not Found with d.get(1) if it is, in fact, an array. Just as an example, here's a quick check I did:

    var d = {0 => "t"}, e = [1], x, y;
    
    x = d[1];       // null
    y = d.get(1);   // null
    
    x = e[1];       // Array Out of Bounds error
    y = e.get(1);   // Symbol Not Found error

    These represent expected behaviors for Dictionaries (which will return null if the requested key does not exist) and Arrays, respectively.

    We'll have to do some more in-depth investigation to see if we can reproduce when dealing with storage or converting from JSON. I am curious how exactly you're handling the JSON response, so if you have any code snippet you can share that demonstrates how you have this implemented, I'd appreciate it.

Children