diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-03-21 06:58:56 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-03-21 06:58:56 -0700 |
commit | e64bfa71cdb0f3be303ebb872e05540497197a58 (patch) | |
tree | db587ea555d1369cd7a32e4d41fd87993b5e778a | |
parent | 97cb10c4bd79c3955f718692b0694de0a26d8d8e (diff) | |
download | txr-e64bfa71cdb0f3be303ebb872e05540497197a58.tar.gz txr-e64bfa71cdb0f3be303ebb872e05540497197a58.tar.bz2 txr-e64bfa71cdb0f3be303ebb872e05540497197a58.zip |
compiler: let* bugfix: not extending env.
* share/txr/stdlib/compiler.tl (sys:env extend-var*):
New method.
(compiler comp-let): When doing sequential bindings, we must
still add the variable to the environment even if there is no
init-form. Oops! Since we're not doing any gensym renaming
trick in this case but binding the real symbol directly, we
need a binding method that allows duplicates.
-rw-r--r-- | share/txr/stdlib/compiler.tl | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index b5e3d645..47abf573 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -69,7 +69,12 @@ (compile-error me.co.last-form "duplicate variable: ~s" sym)) (let* ((loc ^(v ,(ppred me.lev) ,(pinc me.v-cntr))) (bn (new binding sym sym loc loc env me))) - (set me.vb (acons-new sym bn me.vb)))) + (set me.vb (acons sym bn me.vb)))) + + (:method extend-var* (me sym) + (let* ((loc ^(v ,(ppred me.lev) ,(pinc me.v-cntr))) + (bn (new binding sym sym loc loc env me))) + (set me.vb (acons sym bn me.vb)))) (:method extend-fun (me sym) (when (assoc sym me.fb) @@ -358,7 +363,8 @@ (pend frag.code (maybe-mov bind.loc frag.oreg)) (set ffuns (uni ffuns frag.ffuns) - fvars (uni fvars frag.fvars))))))))) + fvars (uni fvars frag.fvars)))) + (t (if seq nenv.(extend-var* sym)))))))) (bfrag me.(comp-progn oreg nenv body)) (boreg (if env.(out-of-scope bfrag.oreg) oreg bfrag.oreg))) (new (frag boreg |