From 3d62624b2b491cfc48deffd7de43771e85da639b Mon Sep 17 00:00:00 2001 From: "O'Keefe, Colin B" Date: Tue, 19 Sep 2023 10:29:02 -0700 Subject: [PATCH] pattern var environment fix --- src/parser/renamer.lisp | 47 +++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/src/parser/renamer.lisp b/src/parser/renamer.lisp index ab86c90f2..fcc9e3615 100644 --- a/src/parser/renamer.lisp +++ b/src/parser/renamer.lisp @@ -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)