You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Currently, literal numbers are interpreted as i64. This can have some annoying interactions when promoting types. For example, the get function:
get<K: key, V: any>(key: K, map: map<K, V>) -> V
requires the key and the map key to be type K: key, where key is any hashable type. However, if we try:
f1: get(4, Input.u64_to_s)
we interpret the 4 as an i64. Then, because we want the map key (a u64) to be the same type as the literal, we have to do the least upper bound of i64 and u64. This is an f64. Unfortunately, f64 is not hashable, and is thus not a key type class.
Expected Behavior
It would make sense if the literal could be interpreted in the context of the types around it -- i.e. it should be a u64.
The text was updated successfully, but these errors were encountered:
jordanrfrazier
changed the title
feat: Interpret literal numbers as the most "obvious" type
feat: Interpret literal numbers in the context of other parameters
Jul 18, 2023
jordanrfrazier
changed the title
feat: Interpret literal numbers in the context of other parameters
feat: Interpret literal number types in the context of other parameters
Jul 18, 2023
Description
Currently, literal numbers are interpreted as
i64
. This can have some annoying interactions when promoting types. For example, theget
function:requires the
key
and themap
key to be typeK: key
, wherekey
is any hashable type. However, if we try:we interpret the
4
as ani64
. Then, because we want themap
key (au64
) to be the same type as the literal, we have to do the least upper bound ofi64
andu64
. This is anf64
. Unfortunately,f64
is not hashable, and is thus not akey
type class.Expected Behavior
It would make sense if the literal could be interpreted in the context of the types around it -- i.e. it should be a
u64
.The text was updated successfully, but these errors were encountered: