clasp-developers / clasp

clasp Common Lisp environment
https://clasp-developers.github.io/
2.56k stars 144 forks source link

CLTL2 readers fail on bytecode environments #1579

Open Bike opened 5 months ago

Bike commented 5 months ago

For example,

(let (x)
  (macrolet ((e (&environment e) (clasp-cltl2:variable-information 'x e)))
    (e)))

compiled as bytecode results in an error: The slot CLEAVIR-ENVIRONMENT::%TYPE in the object #<CLEAVIR-ENVIRONMENT:LEXICAL-VARIABLE-INFO @0x7c6ef516a309> is unbound.

The problem lies in the cleavir-env readers for bytecode lexenvs, which are a bit half-assed - as the comment says, "this will probably not go well". function-info is possibly also a bit broken, and the other env readers like optimize probably need some elbow grease as well.

It would be pretty easy to "fix" this by putting in dummy types (i.e. T) but thanks to the BTB changes, all this information is accessible somewhere or another in the lexenv, and we probably ought to extract it.

This has been an issue for at least a few weeks. paulapatience noticed it when I changed eval to always go through bytecode.