Repository: kdr-aus/ogma (rust)

Issue:
[BUG]
## Current Behaviour

Compiler error:
```
┃>> open ##### | let {nth 0 get:Num ###} $start {last get:Num ###} $end                                                                                                             
┃Typing Error: Type resolution failed                                                                                                                                                                  ┃--> shell:62                                                                                                                                                                                          
┃ | open #### | let {nth 0 get:Num ###} $start {last get:Num ###} $end                                                                                                             
┃ |                                                               ^^^^^^^^^^^^^^^^^^ this node is only inferred                                                                                        ┃
┃--> <ogma>:46                                                                                                                                                                                         
┃ | def last Table (expr:Expr) { nth {len | - 1} $expr }                                                                                                                                               ┃ |                                               ^^^^ but this node is has stronger type garauntees                                                                                                   
┃--> help: this is an internal bug, please report it at <https://github.com/kdr-aus/ogma/issues>                                                                                                       
┃Please supply this BACKTRACE:                                                                                                                                                                         
┃   0: ogma::eng::comp::resolve_tg::<impl ogma::eng::Compiler>::resolve_tg                                                                                                                             
┃   1: ogma::eng::comp::<impl ogma::eng::Compiler>::compile                                                                                                                                            
┃   2: ogma::eng::comp::compile_with_seed_vars                                                                                                                                                         ┃   3: std::sys_common::backtrace::__rust_begin_short_backtrace                                                                                                                                        ┃   4: core::ops::function::FnOnce::call_once{{vtable.shim}}                                                                                                                                           
┃   5: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once                                                                                                                        
┃             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9                                                                                                     
┃      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once                                                                                                                        
┃             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/alloc/src/boxed.rs:1853:9                                                                                                     
┃      std::sys::unix::thread::Thread::new::thread_start                                                                                                                                               
┃             at /rustc/7737e0b5c4103216d6fd8cf941b7ab9bdbaace7c/library/std/src/sys/unix/thread.rs:108:17                                                                                             
┃   6: start_thread                                                                                                                                                                                    
┃   7: clone
```

## Expected Behaviour

## Reproduction Steps
1. 

### Additional information


Pull request:
Extend the backpropagation if the to.input is Known
Fixes #104

Patch:
diff --git a/ogma/src/eng/comp/resolve_tg.rs b/ogma/src/eng/comp/resolve_tg.rs
index a5c0b47..99e3983 100644
--- a/ogma/src/eng/comp/resolve_tg.rs
+++ b/ogma/src/eng/comp/resolve_tg.rs
@@ -48,7 +48,7 @@ impl<'d> Compiler<'d> {
                 ));
                 err.traces.push(Trace::from_tag(
                     to,
-                    "but this node is has stronger type garauntees".to_string(),
+                    "but this node has stronger type guarantees".to_string(),
                 ));
                 err.help_msg = Error::internal_err_help();
             }
diff --git a/ogma/src/eng/graphs/tygraph.rs b/ogma/src/eng/graphs/tygraph.rs
index 7c20ddc..a7da46f 100644
--- a/ogma/src/eng/graphs/tygraph.rs
+++ b/ogma/src/eng/graphs/tygraph.rs
@@ -384,8 +384,8 @@ impl TypeGraph {
                     from.output.can_flow(&to.output).map_err(reserr)?;
                     Some((Update::ToOutput, from.output.clone()))
                 }
-                // Backpropagate flow if to.input:Obliged -> from.input
-                Flow::II if matches!(to.input, Knowledge::Obliged(_)) => {
+                // Backpropagate flow if to.input:Obliged | Known -> from.input
+                Flow::II if matches!(to.input, Knowledge::Obliged(_) | Knowledge::Known(_)) => {
                     to.input.can_flow(&from.input).map_err(reserr)?;
                     Some((Update::FromInput, to.input.clone()))
                 }
@@ -556,7 +556,7 @@ impl Knowledge {
     /// Checks that the this knowledge can 'flow' into the knowledged at `into`.
     ///
     /// Flow is driven by two aspects:
-    /// 1. The ranking of the knowledge (`Known` is the strongest garauntee),
+    /// 1. The ranking of the knowledge (`Known` is the strongest guarantee),
     /// 2. The types match.
     ///
     /// If there is a conflict between the two pieces of knowledge, a `Err(Conflict)` is returned.


Test patch:
diff --git a/ogma/tests/commands/mod.rs b/ogma/tests/commands/mod.rs
index 9d6acc8..0cc4629 100644
--- a/ogma/tests/commands/mod.rs
+++ b/ogma/tests/commands/mod.rs
@@ -773,3 +773,15 @@ fn def_locals_not_type_resolving() {
     let x = process_w_nil("foo { \\ 'foo' | + 'zog' }", defs);
     assert_eq!(x, Ok(Value::Bool(true)));
 }
+
+#[test]
+fn type_resolution_failure() {
+    let x = process_w_nil(
+        "ls | let {nth 0 get:Num size} $start {last get:Num size} $end | \\ #t",
+        &Definitions::new(),
+    );
+    if let Err(e) = &x {
+        println!("{e}");
+    }
+    assert_eq!(x, Ok(Value::Bool(true)));
+}
diff --git a/ogma/tests/doc-examples.rs b/ogma/tests/doc-examples.rs
index 8d3dadb..58af815 100644
--- a/ogma/tests/doc-examples.rs
+++ b/ogma/tests/doc-examples.rs
@@ -2,7 +2,7 @@ use libs::divvy::Str;
 use ogma::lang::ast::Location;
 use ogma::lang::{Definitions, Value};
 use std::path::Path;
-use table::Entry::{self, Nil};
+use table::Entry;
 
 type Result<T> = std::result::Result<T, ogma::Error>;