Skip to content

Commit

Permalink
pattern var environment fix
Browse files Browse the repository at this point in the history
  • Loading branch information
macrologist committed Sep 19, 2023
1 parent f4fc85e commit 3d62624
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions src/parser/renamer.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,43 @@
(:method ((node node-while-let) ctx)
(declare (type algo:immutable-map ctx)
(values node algo:immutable-map))
(values
(make-node-while-let
:pattern (rename-variables-generic% (node-while-let-pattern node) ctx)
:expr (rename-variables-generic% (node-while-let-expr node) ctx)
:body (rename-variables-generic% (node-while-let-body node) ctx)
:source (node-source node))
ctx))
(let*
((new-bindings
(make-local-vars
(mapcar #'pattern-var-name
(pattern-variables (node-while-let-pattern node)))))

(new-ctx
(algo:immutable-map-set-multiple ctx new-bindings)))


(values
(make-node-while-let
:pattern (rename-variables-generic% (node-while-let-pattern node) new-ctx)
:expr (rename-variables-generic% (node-while-let-expr node) ctx)
:body (rename-variables-generic% (node-while-let-body node) new-ctx)
:source (node-source node))
new-ctx)))

(:method ((node node-for) ctx)
(declare (type algo:immutable-map ctx)
(values node algo:immutable-map))
(values
(make-node-for
:pattern (rename-variables-generic% (node-for-pattern node) ctx)
:expr (rename-variables-generic% (node-for-expr node) ctx)
:body (rename-variables-generic% (node-for-body node) ctx)
:source (node-source node))
ctx))
(let*
((new-bindings
(make-local-vars
(mapcar #'pattern-var-name
(pattern-variables (node-for-pattern node)))))

(new-ctx
(algo:immutable-map-set-multiple ctx new-bindings)))

(values
(make-node-for
:pattern (rename-variables-generic% (node-for-pattern node) new-ctx)
:expr (rename-variables-generic% (node-for-expr node) ctx)
:body (rename-variables-generic% (node-for-body node) new-ctx)
:source (node-source node))
new-ctx)))

(:method ((node node-loop) ctx)
(declare (type algo:immutable-map ctx)
Expand Down

0 comments on commit 3d62624

Please sign in to comment.