csp.const
does not resolve type of heterogeneous containers properly
#317
Replies: 3 comments 5 replies
-
The fix for this would be to check the type of each element and if the container is heterogeneous, assign it the container type (i.e. Pros: it fixes the bug here |
Beta Was this translation helpful? Give feedback.
-
This is a tough decision. The current behavior was a conscious decision. The thought process is that having heterogenous containers ( that are native types ) is very rare. I would say over 99.9% of lists in this context would be heterogenous.
In some existing cases this can add a considerable amount of overhead to graph building time. So we need to consider whether its worth the overhead in the general case in order to account for the edge case. ( Note that your example can be made to work be resolving T up front with Having said all this, I also agree that the current behavior is pretty bad in the example presented |
Beta Was this translation helpful? Give feedback.
-
Another fun part of this is that a) fails but b) works. a) def g():
u = csp.const([1, 1.2])
csp.print('u', u) b) def g():
u = csp.const([1.2, 1])
csp.print('u', u) |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
If you have multiple typed elements in a container, we are currently only resolving the type based on the first element. This leads to incorrect behaviour.
To Reproduce
Gives
Expected behavior
The code above should print
[1, 'abc']
Error Message
See above
Runtime Environment
0.0.5
3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0]
linux
Additional context
Beta Was this translation helpful? Give feedback.
All reactions