cl-typeck: More type inference
- Renamed "intrinsic" -> "primitive" - I thought it was funny, but it's just annoying. - Rename "Uninferred" -> "Inferred" - It's a concrete type, but an inferred one. - Add lifetimes to the Entry API - Categorize does not care about recursive types. You can't have a recursive AST. - Added helpful constructors to the inference engine - Added some overloadable operators to the inference engine - These are a MAJOR work in progress - Reorganized the Inference implementation file by functionality. stdlib: - Updated standard library.
This commit is contained in:
@@ -80,6 +80,7 @@ fn main_menu(prj: &mut Table) -> Result<(), RlError> {
|
||||
"q" | "query" => query_type_expression(prj)?,
|
||||
"r" | "resolve" => resolve_all(prj)?,
|
||||
"s" | "strings" => print_strings(),
|
||||
"a" | "all" => infer_all(prj)?,
|
||||
"t" | "test" => infer_expression(prj)?,
|
||||
"h" | "help" | "" => {
|
||||
println!(
|
||||
@@ -159,6 +160,7 @@ fn query_type_expression(prj: &mut Table) -> Result<(), RlError> {
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn infer_expression(prj: &mut Table) -> Result<(), RlError> {
|
||||
read_and(C_RESV, "ex>", "!?>", |line| {
|
||||
if line.trim().is_empty() {
|
||||
@@ -238,6 +240,24 @@ fn resolve_all(table: &mut Table) -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn infer_all(table: &mut Table) -> Result<(), Box<dyn Error>> {
|
||||
for (id, error) in InferenceEngine::new(table, table.root()).infer_all() {
|
||||
match error {
|
||||
InferenceError::Mismatch(a, b) => {
|
||||
eprint!("Mismatched types: {}, {}", table.entry(a), table.entry(b));
|
||||
}
|
||||
InferenceError::Recursive(a, b) => {
|
||||
eprint!("Recursive types: {}, {}", table.entry(a), table.entry(b));
|
||||
}
|
||||
e => eprint!("{e}"),
|
||||
}
|
||||
eprintln!(" in {} ({id})", id.to_entry(table))
|
||||
}
|
||||
|
||||
println!("...Inferred!");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn list_types(table: &mut Table) {
|
||||
for handle in table.debug_entry_iter() {
|
||||
let id = handle.id();
|
||||
|
||||
Reference in New Issue
Block a user