mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 11:41:21 +00:00
debug
This commit is contained in:
parent
09a7452bb5
commit
5bd5378f30
3 changed files with 42 additions and 15 deletions
|
|
@ -3018,7 +3018,14 @@ impl<'a, 'db> ArgumentTypeChecker<'a, 'db> {
|
|||
// building them in an earlier separate step.
|
||||
let when =
|
||||
argument_type.when_assignable_to(self.db, expected_ty, self.inferable_typevars);
|
||||
eprintln!("--> when {}", when.display(self.db));
|
||||
eprintln!("===> check argument");
|
||||
eprintln!(" --> arg {}", argument_type.display(self.db));
|
||||
eprintln!(" --> param {}", expected_ty.display(self.db));
|
||||
eprintln!(" --> when {}", when.display(self.db));
|
||||
eprintln!(
|
||||
" --> sat {}",
|
||||
when.satisfied_by_all_typevars(self.db, self.inferable_typevars)
|
||||
);
|
||||
if !argument_type
|
||||
.when_assignable_to(self.db, expected_ty, self.inferable_typevars)
|
||||
.satisfied_by_all_typevars(self.db, self.inferable_typevars)
|
||||
|
|
|
|||
|
|
@ -1390,6 +1390,7 @@ impl<'db> SpecializationBuilder<'db> {
|
|||
mut f: &mut dyn FnMut(TypeVarAssignment<'db>) -> Option<Type<'db>>,
|
||||
) -> Result<(), SpecializationError<'db>> {
|
||||
if formal == actual {
|
||||
eprintln!(" --> AAA");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
@ -1468,6 +1469,7 @@ impl<'db> SpecializationBuilder<'db> {
|
|||
.satisfied_by_all_typevars(self.db, InferableTypeVars::None)
|
||||
});
|
||||
if assignable_elements.exactly_one().is_ok() {
|
||||
eprintln!(" --> BBB");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -876,19 +876,22 @@ impl<'db> Signature<'db> {
|
|||
let mut check_types = |type1: Option<Type<'db>>, type2: Option<Type<'db>>| {
|
||||
let type1 = type1.unwrap_or(Type::unknown());
|
||||
let type2 = type2.unwrap_or(Type::unknown());
|
||||
!result
|
||||
.intersect(
|
||||
db,
|
||||
type1.has_relation_to_impl(
|
||||
db,
|
||||
type2,
|
||||
inferable,
|
||||
relation,
|
||||
relation_visitor,
|
||||
disjointness_visitor,
|
||||
),
|
||||
)
|
||||
.is_never_satisfied(db)
|
||||
eprintln!(" --> check param");
|
||||
eprintln!(" {}", type1.display(db));
|
||||
eprintln!(" {}", type2.display(db));
|
||||
let x = type1.has_relation_to_impl(
|
||||
db,
|
||||
type2,
|
||||
inferable,
|
||||
relation,
|
||||
relation_visitor,
|
||||
disjointness_visitor,
|
||||
);
|
||||
eprintln!(" x {}", x.display(db),);
|
||||
let y = result.intersect(db, x);
|
||||
eprintln!(" y {}", y.display(db),);
|
||||
eprintln!(" ? {}", !y.is_never_satisfied(db));
|
||||
!y.is_never_satisfied(db)
|
||||
};
|
||||
|
||||
// Return types are covariant.
|
||||
|
|
@ -932,6 +935,7 @@ impl<'db> Signature<'db> {
|
|||
let Some(next_parameter) = parameters.next() else {
|
||||
// All parameters have been checked or both the parameter lists were empty. In
|
||||
// either case, `self` is a subtype of `other`.
|
||||
eprintln!(" --> X1 {}", result.display(db));
|
||||
return result;
|
||||
};
|
||||
|
||||
|
|
@ -952,6 +956,7 @@ impl<'db> Signature<'db> {
|
|||
// `other`, then the non-variadic parameters in `self` must have a default
|
||||
// value.
|
||||
if default_type.is_none() {
|
||||
eprintln!(" --> X2");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
}
|
||||
|
|
@ -964,6 +969,7 @@ impl<'db> Signature<'db> {
|
|||
EitherOrBoth::Right(_) => {
|
||||
// If there are more parameters in `other` than in `self`, then `self` is not a
|
||||
// subtype of `other`.
|
||||
eprintln!(" --> X3");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
|
||||
|
|
@ -984,12 +990,14 @@ impl<'db> Signature<'db> {
|
|||
},
|
||||
) => {
|
||||
if self_default.is_none() && other_default.is_some() {
|
||||
eprintln!(" --> X4");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
if !check_types(
|
||||
other_parameter.annotated_type(),
|
||||
self_parameter.annotated_type(),
|
||||
) {
|
||||
eprintln!(" --> X5");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1005,16 +1013,19 @@ impl<'db> Signature<'db> {
|
|||
},
|
||||
) => {
|
||||
if self_name != other_name {
|
||||
eprintln!(" --> X6");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
// The following checks are the same as positional-only parameters.
|
||||
if self_default.is_none() && other_default.is_some() {
|
||||
eprintln!(" --> X7");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
if !check_types(
|
||||
other_parameter.annotated_type(),
|
||||
self_parameter.annotated_type(),
|
||||
) {
|
||||
eprintln!(" --> X8");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1028,6 +1039,7 @@ impl<'db> Signature<'db> {
|
|||
other_parameter.annotated_type(),
|
||||
self_parameter.annotated_type(),
|
||||
) {
|
||||
eprintln!(" --> X9");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -1068,6 +1080,7 @@ impl<'db> Signature<'db> {
|
|||
other_parameter.annotated_type(),
|
||||
self_parameter.annotated_type(),
|
||||
) {
|
||||
eprintln!(" --> X10");
|
||||
return result;
|
||||
}
|
||||
parameters.next_other();
|
||||
|
|
@ -1079,6 +1092,7 @@ impl<'db> Signature<'db> {
|
|||
other_parameter.annotated_type(),
|
||||
self_parameter.annotated_type(),
|
||||
) {
|
||||
eprintln!(" --> X11");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
@ -1094,12 +1108,16 @@ impl<'db> Signature<'db> {
|
|||
break;
|
||||
}
|
||||
|
||||
_ => return ConstraintSet::from(false),
|
||||
_ => {
|
||||
eprintln!(" --> X12");
|
||||
return ConstraintSet::from(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eprintln!(" --> YYY");
|
||||
// At this point, the remaining parameters in `other` are keyword-only or keyword variadic.
|
||||
// But, `self` could contain any unmatched positional parameters.
|
||||
let (self_parameters, other_parameters) = parameters.into_remaining();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue