Compare commits

...

3 Commits

7 changed files with 21 additions and 8 deletions

4
Cargo.lock generated
View File

@ -78,7 +78,7 @@ checksum = "53a49587ad06b26609c52e423de037e7f57f20d53535d66e08c695f347df952a"
[[package]] [[package]]
name = "reid" name = "reid"
version = "1.0.0-beta.1" version = "1.0.0-beta.2"
dependencies = [ dependencies = [
"colored", "colored",
"reid-lib", "reid-lib",
@ -87,7 +87,7 @@ dependencies = [
[[package]] [[package]]
name = "reid-lib" name = "reid-lib"
version = "1.0.0-beta.1" version = "1.0.0-beta.2"
dependencies = [ dependencies = [
"llvm-sys", "llvm-sys",
"thiserror", "thiserror",

View File

@ -74,7 +74,7 @@ Big features that I want later but are not necessary:
Smaller features: Smaller features:
- ~~Hex-numbers~~ - ~~Hex-numbers~~
- Bitwise operations - ~~Bitwise operations~~
- ~~Easier way to initialize arrays with a single value~~ - ~~Easier way to initialize arrays with a single value~~
- ~~Void-returns (`return;` for void-returning functions)~~ - ~~Void-returns (`return;` for void-returning functions)~~
- ~~Only include standard library at all if it is imported~~ - ~~Only include standard library at all if it is imported~~

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reid-lib" name = "reid-lib"
version = "1.0.0-beta.1" version = "1.0.0-beta.2"
edition = "2024" edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -1,6 +1,6 @@
[package] [package]
name = "reid" name = "reid"
version = "1.0.0-beta.1" version = "1.0.0-beta.2"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -415,6 +415,7 @@ impl Expression {
// First find unfiltered parameters to binop // First find unfiltered parameters to binop
let lhs_res = lhs.typecheck(state, &typerefs, HintKind::None); let lhs_res = lhs.typecheck(state, &typerefs, HintKind::None);
let rhs_res = rhs.typecheck(state, &typerefs, HintKind::None); let rhs_res = rhs.typecheck(state, &typerefs, HintKind::None);
dbg!(&lhs_res, &rhs_res, &ret_ty);
let lhs_type = state.or_else(lhs_res, TypeKind::Vague(Vague::Unknown), lhs.1); let lhs_type = state.or_else(lhs_res, TypeKind::Vague(Vague::Unknown), lhs.1);
let rhs_type = state.or_else(rhs_res, TypeKind::Vague(Vague::Unknown), rhs.1); let rhs_type = state.or_else(rhs_res, TypeKind::Vague(Vague::Unknown), rhs.1);
@ -431,6 +432,8 @@ impl Expression {
params: (lhs_type.clone(), rhs_type.clone()), params: (lhs_type.clone(), rhs_type.clone()),
operator: *op, operator: *op,
}); });
dbg!(&binops);
// dbg!(&lhs_type, &rhs_type, &binops, &ret_ty, &expected_return_ty); // dbg!(&lhs_type, &rhs_type, &binops, &ret_ty, &expected_return_ty);
if let Some(binop) = binops if let Some(binop) = binops
.iter() .iter()

View File

@ -285,8 +285,8 @@ impl Block {
let rhs_ref = state.ok(rhs_infer, rhs.1); let rhs_ref = state.ok(rhs_infer, rhs.1);
// Try to narrow the lhs with rhs // Try to narrow the lhs with rhs
if let (Some(mut lhs_ref), Some(rhs_ref)) = (lhs_ref, rhs_ref) { if let (Some(mut lhs_ref), Some(mut rhs_ref)) = (lhs_ref, rhs_ref) {
lhs_ref.narrow(&rhs_ref); rhs_ref.narrow(&lhs_ref);
} }
} }
StmtKind::Import(_) => panic!(), StmtKind::Import(_) => panic!(),

View File

@ -356,6 +356,12 @@ impl<'outer> ScopeTypeRefs<'outer> {
rhs_ref.narrow(&self.from_type(&rhs_widened).unwrap()); rhs_ref.narrow(&self.from_type(&rhs_widened).unwrap());
} }
} }
(TypeRefKind::BinOp(_, lhs1, rhs1), TypeRefKind::BinOp(_, lhs2, rhs2)) => {
let mut lhs_ref = self.from_type(&lhs1).unwrap();
let mut rhs_ref = self.from_type(&rhs1).unwrap();
lhs_ref.narrow(&self.from_type(&lhs2).unwrap());
rhs_ref.narrow(&self.from_type(&rhs2).unwrap());
}
_ => {} _ => {}
} }
@ -366,7 +372,11 @@ impl<'outer> ScopeTypeRefs<'outer> {
*idx.borrow_mut() = *hint1.0.borrow(); *idx.borrow_mut() = *hint1.0.borrow();
} }
} }
(TypeRefKind::Direct(_), TypeRefKind::BinOp(..)) => {} (TypeRefKind::Direct(_), TypeRefKind::BinOp(..)) => {
if *idx == hint1.0 && idx != &hint2.0 {
*idx.borrow_mut() = *hint2.0.borrow();
}
}
(TypeRefKind::BinOp(..), TypeRefKind::Direct(..)) => { (TypeRefKind::BinOp(..), TypeRefKind::Direct(..)) => {
// TODO may not be good ? // TODO may not be good ?
// if *idx == hint2.0 && idx != &hint1.0 { // if *idx == hint2.0 && idx != &hint1.0 {