From c40a3011b64889f85bde069c8d1365c047360c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Tue, 27 May 2025 13:54:05 +0200 Subject: [PATCH] bytecmp: import_cmpenv registers a function boundary in the end This is to avoid a situation where the form evaluated by CMP-EVAL treats the compiler environment as its own local environment. That caused recently a regression, because we count indexes in FIFO order for sake of dlat closures Before local closures: v first from top (correct) [compiler-env-record form-record] After local closures v first from bottom (incorrect) [compiler-env-record form-record] After this commit: v first from bottom after the boundary [compiler-env-record | form-record] --- src/c/compiler.d | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/c/compiler.d b/src/c/compiler.d index 61f8244dd..72185abfd 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -557,9 +557,10 @@ import_lexenv(cl_env_ptr env, cl_object lexenv) * suitable compiler enviroment to compile forms that access the * variables and local functions of this interpreted code. */ - cl_object record; cl_object *lex = lexenv->vector.self.t; cl_index index = lexenv->vector.dim; + cl_compiler_env_ptr c_env = env->c_env; + cl_object record; while(index>0) { index--; record = lex[index]; @@ -587,10 +588,9 @@ import_lexenv(cl_env_ptr env, cl_object lexenv) } } /* INV we register a function boundary so that objects are not looked for in - the parent locals. Top environment must have env->captured bound because - ecl_make_lambda will call c_any_ref on the parent env. -- jd 2025-01-13*/ + the parent locals. -- jd 2025-01-13*/ c_register_boundary(env, @'si::function-boundary'); - env->c_env->lex_env = lexenv; + c_env->lex_env = lexenv; } static void @@ -601,10 +601,10 @@ import_cmpenv(cl_env_ptr env, cl_object cmpenv) cl_object variables = ECL_CONS_CAR(cmpenv); cl_object functions = ECL_CONS_CDR(cmpenv); cl_compiler_env_ptr c_env = env->c_env; + cl_object record, reg0, reg1; c_env->variables = variables; c_env->macros = functions; loop_for_on_unsafe(variables) { - cl_object record, reg0, reg1; record = ECL_CONS_CAR(variables); if (ECL_ATOM(record)) continue; @@ -617,6 +617,9 @@ import_cmpenv(cl_env_ptr env, cl_object cmpenv) break; } } end_loop_for_on_unsafe(); + /* INV we register a function boundary so that objects are not looked for in + the parent locals. -- jd 2025-01-13*/ + c_register_boundary(env, @'si::function-boundary'); } static void