-
Notifications
You must be signed in to change notification settings - Fork 181
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
Handling integer/float variables #327
Comments
So, I'm a little confused about this. Why would/does it matter that there can multiple "integer types" vs. |
From Chalk's view, |
(An additional complication is that we in general don't want to enumerate a potentially completely open set of types for solutions, but in this case the actual set of possible types that the variable can take is very constrained from the outset.) |
Actually, it might be possible to model this using a hidden enumerable |
Yes, I was thinking about that as a solution (it was my first thought). |
I used to favor an integer trait, but these days I'm thinking we will regret trying to be too clever, and we should just add more entries to |
I feel like it's not that much complexity to add and somehow I think we are going to find that using a special trait is going to be more trouble than it's worth. |
The trait solution wouldn't work in the recursive solver anyway, at least. |
I'm interested in working on this, it looks like the design is thought-out enough to start experimenting with the implementation? I don't see it mentioned yet, but following rustc we would have an |
Indeed, I think if we just go with the rustc way of approaching this, it should be fairly straightforward to implement. There wouldn't be a different
and there is a Floats are distinguished from ints because we actually know that from parsing. |
So to transform that example into a test, it would look something like this? test! {
program {
trait Foo {}
struct Bar {}
impl Foo for usize {}
impl Foo for Bar {}
}
goal {
exists<int N> {
N: Foo
}
} yields {
"Unique; substitution [?0 := usize]"
}
} |
Yes, that looks right |
@rustbot claim I've got a working implementation of integer kinded variables (:tada:), and after I extend it to floats I'll open a PR. |
Integer literals of unspecified type like e.g.
1
get assigned an 'integer type' variable in Rust, which is for most uses like a normal type variable, but we know it can only be one of the integer types. The same goes for float literals. Chalk mostly doesn't care about this, but it can lead us to a non-ambiguous solution because in some cases, only one solution actually is an integer type. The most notable example (I think) happens when indexing into an array or slice:i
gets inferred tousize
here because that's the only integer type for whichIndex
is implemented in this case, as far as I understand. Chalk currently can't do this.There was already some discussion about this in a Zulip stream a while ago; I thought I'd open a ticket to keep track of the problem.
The text was updated successfully, but these errors were encountered: