define an empty lambda as an empty function
A lifted function with no body was a declaration of one, and nothing defined it, so the program did not link.
This commit is contained in:
21
semen.scm
21
semen.scm
@@ -1516,10 +1516,17 @@
|
||||
(string->symbol
|
||||
(fmt #f "λ" counter "_" enclosing-fn-name)))
|
||||
|
||||
;;; A function with no body is a declaration, and nothing would define
|
||||
;;; one lifted from an empty lambda; an empty block keeps it a definition,
|
||||
;;; and the writer leaves the block out
|
||||
(define (defining body)
|
||||
(if (every comment-form? body) (append body (list '(do))) body))
|
||||
|
||||
(define (lift-lambda name form)
|
||||
(match form
|
||||
(('lambda arglist ret-type . body)
|
||||
(process-fn (copy-form-source! form `(fn ,name ,arglist ,ret-type ,@body))
|
||||
(process-fn (copy-form-source! form `(fn ,name ,arglist ,ret-type
|
||||
,@(defining body)))
|
||||
(list)))
|
||||
(else (sex-error form "malformed lambda" form))))
|
||||
|
||||
@@ -1855,11 +1862,13 @@
|
||||
|
||||
(list
|
||||
`(fn ,code ((ƛe (* void)) ,@(named-parameters arglist)) ,ret-type
|
||||
,@(if (null? caps)
|
||||
(list)
|
||||
`((var ƛcaptures (* (struct ,record)) ƛe)
|
||||
,@(append-map (cut capture-local <> form) caps)))
|
||||
,@body)
|
||||
,@(defining
|
||||
(append
|
||||
(if (null? caps)
|
||||
(list)
|
||||
`((var ƛcaptures (* (struct ,record)) ƛe)
|
||||
,@(append-map (cut capture-local <> form) caps)))
|
||||
body)))
|
||||
|
||||
`(fn ,construct ,caps (struct ,closure)
|
||||
(var ƛc (struct ,closure))
|
||||
|
||||
Reference in New Issue
Block a user