Add more defaulting
This commit is contained in:
@@ -847,22 +847,39 @@ pub fn solve_constraints(
|
||||
if !changed_something {
|
||||
let mut addendums = vec![];
|
||||
|
||||
new_constraints.retain(|x| {
|
||||
if let Constraint::ConstantNumericType(loc, t) = x {
|
||||
macro_rules! default_type {
|
||||
($addendums: ident, $loc: ident, $t: ident) => {
|
||||
let resty = TypeOrVar::Primitive(PrimitiveType::U64);
|
||||
addendums.push(Constraint::Equivalent(
|
||||
loc.clone(),
|
||||
t.clone(),
|
||||
$addendums.push(Constraint::Equivalent(
|
||||
$loc.clone(),
|
||||
$t.clone(),
|
||||
resty.clone(),
|
||||
));
|
||||
warnings.push(TypeInferenceWarning::DefaultedTo(loc.clone(), resty));
|
||||
warnings.push(TypeInferenceWarning::DefaultedTo($loc.clone(), resty));
|
||||
tracing::trace!("Adding number equivalence");
|
||||
};
|
||||
}
|
||||
|
||||
new_constraints.retain(|x| {
|
||||
if let Constraint::ConstantNumericType(loc, t) = x {
|
||||
default_type!(addendums, loc, t);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
|
||||
if addendums.is_empty() {
|
||||
new_constraints.retain(|x| {
|
||||
if let Constraint::IsSomething(loc, t) = x {
|
||||
default_type!(addendums, loc, t);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if addendums.is_empty() {
|
||||
if errors.is_empty() {
|
||||
errors = new_constraints
|
||||
|
||||
Reference in New Issue
Block a user