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]
This commit is contained in:
Daniel Kochmański 2025-05-27 13:54:05 +02:00
parent ba891a5094
commit c40a3011b6

View file

@ -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