From 4e95ee830ad9db5dd2620791477c31a95feb17f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Thu, 19 Dec 2024 09:22:34 +0100 Subject: [PATCH] tests: add a failing test for minimal closures --- src/tests/normal-tests/compiler.lsp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tests/normal-tests/compiler.lsp b/src/tests/normal-tests/compiler.lsp index 5600caa21..d8e30ae93 100644 --- a/src/tests/normal-tests/compiler.lsp +++ b/src/tests/normal-tests/compiler.lsp @@ -2465,3 +2465,15 @@ (finishes (is (null (nth-value 2 (compile nil f2))))) (print (= (funcall f1 3) 6)) (print (= (funcall f2 3) 5))))) + +;;; Date 2024-12-19 +;;; Description +;;; +;;; Make sure that FLET and LABELS do not create a closure when the lexenv +;;; contains only objects that are not referenced. Similar to cmp.0066. +;;; +(test cmp.0102.bytecodes-flat-closure + (let ((fun (let ((b 3)) (flet ((a () 1)) #'a)))) + (is (null (nth-value 1 (function-lambda-expression fun))))) + (let ((fun (let ((b 3)) (labels ((a () 1)) #'a)))) + (is (null (nth-value 1 (function-lambda-expression fun))))))