space toplevel forms the way the source does

Every toplevel form was followed by a blank line whether or not one
was written, so the prelude's run of typedefs arrived at twice the
height. A function had no location of its own to measure from either,
having lost it where its header and body are stitched together.
This commit is contained in:
2026-10-05 02:08:15 +03:00
parent 7f3f22e853
commit 95f39e4b44
8 changed files with 72 additions and 25 deletions

View File

@@ -254,7 +254,7 @@
;; emits the comment immediately before the declaration
(cons form
(if doc
(cons (list 'comment doc) acc)
(cons (copy-form-source! form (list 'comment doc)) acc)
acc)))
(define (strip-fn-header-comments fn-form)
@@ -277,7 +277,11 @@
;; the parameters are the body's outermost scope
(header (map resolve-closure-types (take expanded boundary)))
(body (walk-body (drop expanded boundary) env))
(processed (append header body)))
;; A function is header and body stitched together, so the
;; result is fresh structure: without this the definition
;; has no location, and nothing downstream can say where
;; the function was written
(processed (copy-form-source! sex-fn-raw (append header body))))
(with-docstring doc processed
(append (hash-table-ref env :lambda-aux-code) acc))))))