From 0636eb3b8d642023419677721d228ad1d90418a3 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Fri, 25 Sep 2026 11:47:11 +0700 Subject: [PATCH] A generic's copy that the file does not make is named in its lowering rather than left out --- TODO.org | 9 +++++++++ emacs/flan-lower.el | 24 +++++++++++++----------- lib/dev.ml | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/TODO.org b/TODO.org index f61963d2..e71d0d34 100644 --- a/TODO.org +++ b/TODO.org @@ -1051,6 +1051,10 @@ should not pay for identity and metadata. Not implemented. function nosuch" twice at the same place and counts 2 errors — once from the abstract pass and once from the instantiation. +** TODO A type variable is printed without its $ +=Types.to_string= prints =Var t= as =t=, so a refusal reads "selection-sort +expects [t] here, found [3 i32]" where the source wrote =[$t]=. + ** DONE Two refusals suggested something that does not compile CLOSED: [2026-09-25] =vec-new= and =map-new= with no type no longer say "or give the binding a type"; @@ -1900,6 +1904,11 @@ C-x C-e thunk triggered. Needs reproducing under load and fixing. * Editor +** TODO C-c C-l on a generic needs a session to find its copies +The lowering view compiles the file, but only the daemon's =defs= says which +functions are a generic's copies, so with no session a generic's name shows +nothing. Needs a way to ask the compiler for a file's copies of a name. + ** DONE The syntax table and the font-lock lists are read off the parser CLOSED: [2026-09-21] The special-form list is the heads the parser dispatches on, the builtin list is diff --git a/emacs/flan-lower.el b/emacs/flan-lower.el index 4ca995a5..6562f7d1 100644 --- a/emacs/flan-lower.el +++ b/emacs/flan-lower.el @@ -435,17 +435,19 @@ function that happens to share the prefix, `sort-bytes' beside `sort'." #'string<))))) (defun flan-lower--fetch-copies (section name) - "SECTION for each copy of generic NAME, each under a line naming it, or nil." - (let ((parts - (delq nil - (mapcar - (lambda (c) - (let ((text (funcall flan-lower-fetch-function - section flan-lower--file c - flan-lower--flags))) - (and text (format ";; %s\n%s" c text)))) - (flan-lower--copies name))))) - (and parts (mapconcat #'identity parts "\n")))) + "SECTION for each copy of generic NAME, each under a line naming it, or nil. +The copies are the session's, and the file may call the generic at fewer +types than the session does; a copy the file does not make is named as such +rather than left out." + (let ((copies (flan-lower--copies name))) + (and copies + (mapconcat + (lambda (c) + (format ";; %s\n%s" c + (or (funcall flan-lower-fetch-function + section flan-lower--file c flan-lower--flags) + "not made by this file: nothing in it calls at these types\n"))) + copies "\n")))) (defun flan-lower--gather (sections) "Fetch each of SECTIONS into `flan-lower--texts', replacing what was there. diff --git a/lib/dev.ml b/lib/dev.ml index 68f61af1..bd1ffd21 100644 --- a/lib/dev.ml +++ b/lib/dev.ml @@ -686,6 +686,8 @@ let generic_copies t name = Some (f, String.concat ", " bound) | _ -> None) t.session.Session.program.Tast.fns + (* By the types, alphabetically — [f64] before [i32] — so a listing asked + for twice is in the same order whatever order the copies were made in. *) |> List.sort (fun (_, a) (_, b) -> String.compare a b) (* ── Ops ───────────────────────────────────────────────────────────── *)