#276 flet/labels local functions lack implicit block (return-from misses)
openOn build/funcl (real binary), ANSI data-and-control-flow/flet.lsp:
- flet.5:
(flet ((%f () (return-from %f 15) 35)) (%f))-> 35 (should be 15); stderr 'RETURN-FROM-MISS %F'. flet local functions do not establish an implicit block named after the function (CLHS 3.1.2.1.2 / 5.3 — flet/labels functions have an implicit block with the function's name). Same class as cave#148 (defun implicit block) but for flet/labels lifted functions. - flet.4:
(block %f (flet ((%f (&optional (x (return-from %f :good))) nil)) (%f) :bad))-> :bad (should be :good). return-from to an OUTER block from an &optional default form in a flet fails. - flet.7:
(flet ((%f (x) (+ x 5))) (flet ((%f (y) (cond ((eql y 20) 30) (t (%f 20))))) (%f 15)))-> Error 'The value %F is not a LIST (car/cdr)'. Nested shadowing flet where inner body references the outer same-named function crashes.
Fix is cold-path (flet is a special form with lift machinery in src/cold/compiler.lisp ~4817-4939); wrap each flet/labels function body in (block FNAME ...) like emit-ir-defun does for cave#148.
Comments (2)
ASSESSMENT 2026-07-11: unchanged — flet/labels locals lack their implicit block, so (return-from NAME …) inside a local misses. The fix shape is known and the device exists: the cave#219 escapify pre-pass already rewrites cross-frame return-from via escape tokens; extending it means wrapping each flet/labels local body in a synthetic (block NAME …) BEFORE lifting so escapify sees the pair. Moderate; touches ag-escapify + the lift path. Related recent win: the same machinery family fixed cave#269 (closed today).
PARTIALLY FIXED (2026-07-11):
STILL OPEN:
NOTE: these only manifest on build/funcl (the real binary). build/funcl-stage2 lacks mini-clos and mis-handles CLOS fixtures — use FUNCL=build/funcl to reproduce.