Add more defaulting
This commit is contained in:
1
examples/basic/test0003.ngr
Normal file
1
examples/basic/test0003.ngr
Normal file
@@ -0,0 +1 @@
|
||||
v = -2370389138213399653i64;
|
||||
4
examples/basic/test0004.ngr
Normal file
4
examples/basic/test0004.ngr
Normal file
@@ -0,0 +1,4 @@
|
||||
function u (t,h,z,u,a,f,c) 27u8;
|
||||
function s (p,y,k) 10318938949979263534u64;
|
||||
o = -98i8;
|
||||
print o;
|
||||
@@ -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