diff --git a/TODO.md b/TODO.md index b4d5b89..402d0f4 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,12 @@ ## TODO +- [ ] "Expected keyword" at `\ a ->` should be error at the `->` - [ ] Show Either - [ ] `local` for `where`-like `let` clauses? (I want a `where` that closes over more stuff) -- [ ] Erasure checking happens at compile time and isn't surfaced to editor.. + - I can do `let f : ... = \ a b c => ...`. But it doesn't work for recursion and cases are awkward. +- [x] Erasure checking happens at compile time and isn't surfaced to editor.. +- [ ] Erasure issue during AoC from case building replacing a non-erased value with erased. - [ ] Add Foldable? - [ ] "Failed to unify %var0 and %var1" - get names in there - Need fancier `Env` diff --git a/src/Lib/ProcessDecl.newt b/src/Lib/ProcessDecl.newt index a5a074b..ebe08b5 100644 --- a/src/Lib/ProcessDecl.newt +++ b/src/Lib/ProcessDecl.newt @@ -181,12 +181,17 @@ processDef ns fc nm clauses = do -- moved to Compile.newt because it was interfering with type checking (Zoo4eg.newt) via over-reduction -- tm' <- zonk top 0 Nil tm + -- for effect, so we see errors in the editor + -- We need to keep the _unerased_ term for checking + _ <- erase Nil tm Nil + debug $ \ _ => "Add def \{nm} \{render 90 $ pprint Nil tm} : \{render 90 $ pprint Nil ty}" updateDef (QN ns nm) fc ty (Fn tm) -- putStrLn "complexity \{show (QN ns nm)} \{show $ complexity tm}" -- putStrLn $ show tm -- TODO we need some protection against inlining a function calling itself. -- We need better heuristics, maybe fuel and deciding while inlining. + -- someday users will tag functions as inline, so maybe an explicit loop check -- IO,bind is explicit here because the complexity has a 100 in it. let name = show $ QN ns nm if complexity tm < 15 || name == "Prelude.Prelude.Monad Prelude.IO,bind" || name == "Prelude._>>=_" diff --git a/tests/aside/Quantity.newt b/tests/Quantity.newt similarity index 100% rename from tests/aside/Quantity.newt rename to tests/Quantity.newt diff --git a/tests/Quantity.newt.fail b/tests/Quantity.newt.fail new file mode 100644 index 0000000..32d9669 --- /dev/null +++ b/tests/Quantity.newt.fail @@ -0,0 +1,10 @@ +*** Process tests/Quantity.newt +module Prelude +module Quantity +ERROR at tests/Quantity.newt:11:15--11:16: used erased value x$0 (FIXME FC may be wrong here) + -- This should fail to compile + bar : ∀ x. Nat + bar {x} = foo x + ^ + +Compile failed