Open thareh opened 1 year ago
The "map = map + 1" generates:
(bbt_map)->clas->m__iset_ii((struct _m_untitled1_TTreeMapii_obj*)bbt_map,bbt_key,((bbt_map)->clas->m__iget_i((struct _m_untitled1_TTreeMapii_obj*)bbt_map,bbt_key)+1));
while "map :+ 1" results in:
(bbt_map)->clas->m__iset_ii((struct _m_untitled1_TTreeMapii_obj*)bbt_map,bbt_key,1);
btw "map = 1" also results in:
(bbt_map)->clas->m__iset_ii((struct _m_untitled1_TTreeMapii_obj*)bbt_map,bbt_key,1);
map[key]
returns the value from the map. It is not a reference to the value within the map.
If you want to change the value within the map, you can map[key] = map[key] + 1
I think the issue is that :+
is a shortcut to x = x +1
while the above code seems to make it x = 1
Hey,
Seems like "self increment" i.e. var :+ 1 for instance isn't working properly with generics.
Switch the commented line with the one beneath it and you'll see the issue at hand.
Thanks and have a good day!