Skip to content

Commit

Permalink
micros/walker: fix let binding
Browse files Browse the repository at this point in the history
  • Loading branch information
cxxxr committed Nov 30, 2023
1 parent ddde60b commit a398778
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
5 changes: 5 additions & 0 deletions contrib/walker/example.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,8 @@
:initially (print foo)
:collect x :into foo
:finally (print foo))

(let ((a 0)
b)
a
b)
24 changes: 24 additions & 0 deletions contrib/walker/tests/test-cases.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3755,3 +3755,27 @@
:DO (MICROS/WALKER::F MICROS/WALKER::N) (MICROS/WALKER::G MICROS/WALKER::N))
(2))
((1 7) (1 6) (2)))
((MICROS/WALKER:COLLECT-HIGHLIGHT-PATHS
(LET ((MICROS/WALKER::A 0) MICROS/WALKER::B)
MICROS/WALKER::A
MICROS/WALKER::B)
(3))
((3) (1 1)))
((MICROS/WALKER:COLLECT-HIGHLIGHT-PATHS
(LET ((MICROS/WALKER::A 0) MICROS/WALKER::B)
MICROS/WALKER::A
MICROS/WALKER::B)
(2))
((2) (0 0 1)))
((MICROS/WALKER:COLLECT-HIGHLIGHT-PATHS
(LET ((MICROS/WALKER::A 0) MICROS/WALKER::B)
MICROS/WALKER::A
MICROS/WALKER::B)
(1 1))
((3) (1 1)))
((MICROS/WALKER:COLLECT-HIGHLIGHT-PATHS
(LET ((MICROS/WALKER::A 0) MICROS/WALKER::B)
MICROS/WALKER::A
MICROS/WALKER::B)
(0 0 1))
((2) (0 0 1)))
7 changes: 5 additions & 2 deletions contrib/walker/walker.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,14 @@
(walk-lambda-form walker form env path))

(defmethod walk-let-binding-form ((walker walker) binding-form env path)
(with-walker-bindings (var value) binding-form
(with-walker-bindings (var value)
(if (consp binding-form)
binding-form
(list binding-form nil))
(assert-type var 'variable-symbol)
(let ((value (walk walker value env (cons 1 path))))
(make-instance 'let-binding-form
:path (cons 0 path)
:path (if (consp binding-form) (cons 0 path) path)
:binding (make-instance 'lexical-variable-binding
:name var
:value value)
Expand Down

0 comments on commit a398778

Please sign in to comment.