Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Interpret literal number types in the context of other parameters #534

Open
jordanrfrazier opened this issue Jul 18, 2023 · 0 comments
Labels
bug Something isn't working enhancement New feature or request sparrow

Comments

@jordanrfrazier
Copy link
Collaborator

jordanrfrazier commented Jul 18, 2023

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.

@jordanrfrazier jordanrfrazier added bug Something isn't working sparrow enhancement New feature or request labels Jul 18, 2023
@jordanrfrazier 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request sparrow
Projects
None yet
Development

No branches or pull requests

1 participant