Improve negative impl inference.#8748
Conversation
f50a08f to
fa5d337
Compare
fa5d337 to
b41dd18
Compare
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 of 6 files at r1, 1 of 5 files at r2, all commit messages.
Reviewable status: 2 of 7 files reviewed, 4 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 215 at r2 (raw file):
} pub fn extract_generic_params(
doc
crates/cairo-lang-semantic/src/types.rs line 218 at r2 (raw file):
&self, db: &'db dyn Database, generic_parameters: &mut HashSet<GenericParamId<'db>>,
Suggestion:
generic_parameters: &mut OrderedHashSet<GenericParamId<'db>>,crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
} } // TODO(ilya): Do we need to extract generic params from the impl.ty?
what generic params?
crates/cairo-lang-semantic/src/types.rs line 249 at r2 (raw file):
} TypeLongId::Closure(_) => { // TODO(ilya): Do we need to extract generic params from the closure??
can it be a closure? isn't it about the signature of the taken impl?
|
Previously, orizi wrote…
the impl can be generic in a closure |
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 2 of 7 files reviewed, 4 unresolved discussions (waiting on @orizi and @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
Previously, orizi wrote…
what generic params?
impl.ty is a type, so it might include generic params, no?
|
Previously, ilyalesokhin-starkware wrote…
I guess its a TraitTypeId, I'm not sure if it has generic params or not. |
b41dd18 to
009ee08
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 2 of 7 files reviewed, 4 unresolved discussions (waiting on @orizi and @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 215 at r2 (raw file):
Previously, orizi wrote…
doc
Done.
crates/cairo-lang-semantic/src/types.rs line 218 at r2 (raw file):
&self, db: &'db dyn Database, generic_parameters: &mut HashSet<GenericParamId<'db>>,
Done.
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed all commit messages.
Reviewable status: 2 of 7 files reviewed, 4 unresolved discussions (waiting on @ilyalesokhin-starkware and @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
Previously, ilyalesokhin-starkware wrote…
I guess its a TraitTypeId, I'm not sure if it has generic params or not.
i think only the impl or trait itself may have params - not the type itself.
crates/cairo-lang-semantic/src/expr/inference.rs line 1193 at r3 (raw file):
} let mut generic_params = OrderedHashSet::default();
or something? without the specificity it is kinda unclear.
Suggestion:
negatic_impl_generic_paramscrates/cairo-lang-semantic/src/expr/inference.rs line 1198 at r3 (raw file):
// If we fail to extract the generic parameters, return that the negative impl is // invalid. return Ok(SolutionSet::None);
or something?
Suggestion:
return Ok(SolutionSet::Ambiguous(
Ambiguity::NegativeImplWithUnsupportedExtractedArgs { concrete_trait_id, ty },
));crates/cairo-lang-semantic/src/types.rs line 215 at r3 (raw file):
} /// A utility function for extractingthe generic paramaters arguments from TypeLongId.
Suggestion:
/// A utility function for extracting the generic paramaters arguments from TypeLongId.009ee08 to
5a4a7bb
Compare
|
If I change this line to test the error , I get the error below, which seems reasonable. Suggestion (i): if garg.extract_generic_params(self.db, &mut generic_params).is_ok() {Code snippet (ii): error: Negative impl has an unsupported [T; 1].
--> lib.cairo:12:5
MyImpl::<T, 1>::f();
^^^^^^ |
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 2 of 7 files reviewed, 5 unresolved discussions (waiting on @orizi and @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
Previously, orizi wrote…
i think only the impl or trait itself may have params - not the type itself.
@TomerStarkware said:
"No, I think we have a todo for it"
What do you want to do about my TODO here?
crates/cairo-lang-semantic/src/expr/inference.rs line 1193 at r3 (raw file):
Previously, orizi wrote…
or something? without the specificity it is kinda unclear.
Done
crates/cairo-lang-semantic/src/expr/inference.rs line 1198 at r3 (raw file):
Previously, orizi wrote…
or something?
Done.
crates/cairo-lang-semantic/src/types.rs line 215 at r3 (raw file):
} /// A utility function for extractingthe generic paramaters arguments from TypeLongId.
Done.
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 of 5 files at r2, 3 of 4 files at r4, all commit messages.
Reviewable status: 6 of 7 files reviewed, 5 unresolved discussions (waiting on @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
Previously, ilyalesokhin-starkware wrote…
@TomerStarkware said:
"No, I think we have a todo for it"What do you want to do about my TODO here?
i think it won't have a useful effect - remove IMO.
crates/cairo-lang-semantic/src/types.rs line 260 at r4 (raw file):
} } TypeLongId::Missing(diag_added) => return Maybe::Err(*diag_added),
it seems error can only happen if the system is broken?
crates/cairo-lang-semantic/src/types.rs line 260 at r4 (raw file):
} } TypeLongId::Missing(diag_added) => return Maybe::Err(*diag_added),
Suggestion:
TypeLongId::Missing(diag_added) => return Err(*diag_added),crates/cairo-lang-semantic/src/expr/inference/solver.rs line 97 at r4 (raw file):
} Ambiguity::NegativeImplWithUnsupportedExtractedArgs(garg) => { format!("Negative impl has an unsupported {:?}.", garg.debug(db),)
Suggestion:
format!("Negative impl has an unsupported arg {:?}.", garg.debug(db),)|
Previously, orizi wrote…
Yes, do you prefer unwrapping or ignoring errors silently? not that I also have a |
5a4a7bb to
8d6f1db
Compare
ilyalesokhin-starkware
left a comment
There was a problem hiding this comment.
Reviewable status: 3 of 7 files reviewed, 4 unresolved discussions (waiting on @orizi and @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 246 at r2 (raw file):
Previously, orizi wrote…
i think it won't have a useful effect - remove IMO.
Done.
crates/cairo-lang-semantic/src/expr/inference/solver.rs line 97 at r4 (raw file):
} Ambiguity::NegativeImplWithUnsupportedExtractedArgs(garg) => { format!("Negative impl has an unsupported {:?}.", garg.debug(db),)
Done.
crates/cairo-lang-semantic/src/types.rs line 260 at r4 (raw file):
} } TypeLongId::Missing(diag_added) => return Maybe::Err(*diag_added),
Done.
orizi
left a comment
There was a problem hiding this comment.
@orizi reviewed 1 of 4 files at r4, 3 of 3 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @TomerStarkware)
crates/cairo-lang-semantic/src/types.rs line 260 at r4 (raw file):
Previously, ilyalesokhin-starkware wrote…
Yes, do you prefer unwrapping or ignoring errors silently?
not that I also have a
?inimpl_type_id.impl_id.concrete_trait(db)?
this is probably better if we think there may be issues.
but we can probably change to "unexpected behavior - report" or something.
TomerStarkware
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 1 unresolved discussion
crates/cairo-lang-semantic/src/types.rs line 241 at r5 (raw file):
TypeLongId::Coupon(_) => {} TypeLongId::FixedSizeArray { type_id, .. } => { type_id.long(db).extract_generic_params(db, generic_parameters)?
The size of the array can be generic as well,
No description provided.