A generic's copy that the file does not make is named in its lowering rather than left out

This commit is contained in:
Joseph Ferano 2026-09-25 11:47:11 +07:00
parent b05a97b029
commit 0636eb3b8d
3 changed files with 24 additions and 11 deletions

View File

@ -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 function nosuch" twice at the same place and counts 2 errors — once from the
abstract pass and once from the instantiation. 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 ** DONE Two refusals suggested something that does not compile
CLOSED: [2026-09-25] CLOSED: [2026-09-25]
=vec-new= and =map-new= with no type no longer say "or give the binding a type"; =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 * 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 ** DONE The syntax table and the font-lock lists are read off the parser
CLOSED: [2026-09-21] CLOSED: [2026-09-21]
The special-form list is the heads the parser dispatches on, the builtin list is The special-form list is the heads the parser dispatches on, the builtin list is

View File

@ -435,17 +435,19 @@ function that happens to share the prefix, `sort-bytes' beside `sort'."
#'string<))))) #'string<)))))
(defun flan-lower--fetch-copies (section name) (defun flan-lower--fetch-copies (section name)
"SECTION for each copy of generic NAME, each under a line naming it, or nil." "SECTION for each copy of generic NAME, each under a line naming it, or nil.
(let ((parts The copies are the session's, and the file may call the generic at fewer
(delq nil types than the session does; a copy the file does not make is named as such
(mapcar rather than left out."
(lambda (c) (let ((copies (flan-lower--copies name)))
(let ((text (funcall flan-lower-fetch-function (and copies
section flan-lower--file c (mapconcat
flan-lower--flags))) (lambda (c)
(and text (format ";; %s\n%s" c text)))) (format ";; %s\n%s" c
(flan-lower--copies name))))) (or (funcall flan-lower-fetch-function
(and parts (mapconcat #'identity parts "\n")))) 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) (defun flan-lower--gather (sections)
"Fetch each of SECTIONS into `flan-lower--texts', replacing what was there. "Fetch each of SECTIONS into `flan-lower--texts', replacing what was there.

View File

@ -686,6 +686,8 @@ let generic_copies t name =
Some (f, String.concat ", " bound) Some (f, String.concat ", " bound)
| _ -> None) | _ -> None)
t.session.Session.program.Tast.fns 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) |> List.sort (fun (_, a) (_, b) -> String.compare a b)
(* ── Ops ───────────────────────────────────────────────────────────── *) (* ── Ops ───────────────────────────────────────────────────────────── *)