-
Notifications
You must be signed in to change notification settings - Fork 39
Refactor ty_is_int
#200
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
base: main
Are you sure you want to change the base?
Refactor ty_is_int
#200
Changes from 5 commits
a889ecd
992f4c2
9980d0e
6ee4489
4379ad6
652dba9
331c737
e237c2d
df0fe30
c0fbd8b
c7f3363
582560e
1f601cf
33d8a48
afd30d2
130f628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,7 +16,9 @@ use crate::{ | |||||||||||||||||||
}; | ||||||||||||||||||||
|
||||||||||||||||||||
use super::constraints::Constraints; | ||||||||||||||||||||
use formality_types::grammar::Parameter::Ty; | ||||||||||||||||||||
use formality_types::grammar::Parameter::{self, Ty}; | ||||||||||||||||||||
use formality_types::grammar::RigidName; | ||||||||||||||||||||
use formality_types::grammar::RigidTy; | ||||||||||||||||||||
|
||||||||||||||||||||
judgment_fn! { | ||||||||||||||||||||
/// The "heart" of the trait system -- prove that a where-clause holds given a set of declarations, variable environment, and set of assumptions. | ||||||||||||||||||||
|
@@ -145,5 +147,30 @@ judgment_fn! { | |||||||||||||||||||
----------------------------- ("const has ty") | ||||||||||||||||||||
(prove_wc(decls, env, assumptions, Predicate::ConstHasType(ct, ty)) => c) | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
( | ||||||||||||||||||||
(is_int(decl, env, assumptions, ty) => c) | ||||||||||||||||||||
----------------------------- ("ty is int") | ||||||||||||||||||||
(prove_wc(decl, env, assumptions, Relation::IsInt(ty)) => c) | ||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how does a-mir-formality handle normalization when proving predicates/relations? Because right now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's true, I did an experiment in 331c737#diff-2ca1246445028c80247cd13d93fd973d22ca55cfb7a76c0903a04c09055d706c and it indeed failed. The place where normalization is done should be here
It is possible to use prove_normalize when proving a goal, for example: a-mir-formality/crates/formality-prove/src/prove/is_local.rs Lines 288 to 295 in 8b130f7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But with the change in c0fbd8b, it is possible to make |
||||||||||||||||||||
) | ||||||||||||||||||||
} | ||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
judgment_fn! { | ||||||||||||||||||||
pub fn is_int( | ||||||||||||||||||||
_decls: Decls, | ||||||||||||||||||||
env: Env, | ||||||||||||||||||||
assumptions: Wcs, | ||||||||||||||||||||
goal: Parameter, | ||||||||||||||||||||
) => Constraints { | ||||||||||||||||||||
debug(goal, assumptions, env) | ||||||||||||||||||||
|
||||||||||||||||||||
( | ||||||||||||||||||||
(if id.is_int()) | ||||||||||||||||||||
------- ("is int") | ||||||||||||||||||||
(is_int(_decls, env, _assumptions, RigidTy {name: RigidName::ScalarId(id), parameters: _}) => Constraints::none(env)) | ||||||||||||||||||||
) | ||||||||||||||||||||
|
||||||||||||||||||||
} | ||||||||||||||||||||
|
||||||||||||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't like introducing a new judgement for this. I think if we want this check to be a proper judgement maybe add a builtin trait and prove
value_ty: BuiltinInteger
here 🤔Even if it's a proper judegement:tm: but instead be just something else you can prove. Predicates feel core to the type system in a way in which "is this an integer" does not. That's just my personal vibe here though
What's the reasoning behind changing an assertion to an actual goal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason of changing this to a goal is I feel we should have a way to say "this type is an int" somewhere instead of having this function https://github.com/rust-lang/a-mir-formality/pull/200/files#diff-b58482e54c5aa3c63282fc2a3a0aa88194e826004773bd7bc9e385f29b5c3e0d
But I do agree that adding a predicate for this might be an overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we instead just use a "non-predicate" judgement here. Same as we do for
trait_ref_is_knowable
or however it's called?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I forgot to mention that I was using a
Relation
instead ofPredicate
.From my understanding, we can only use a
judgment_fn!
throughprove_wc
, and when we callprove_wc
, we need to pick one of the below as the Wc type:Relation
looks the most reasonable to me among all of them.