diff --git a/parse.rkt b/parse.rkt index 94c4319..c41fca0 100644 --- a/parse.rkt +++ b/parse.rkt @@ -151,10 +151,12 @@ [rhss (let-rhss exp)] [body (let-body exp)]) (cond + [(= 0 (length vars)) + (parse `(begin ,@body))] [(= 1 (length vars)) (make-Let1 (car vars) (parse (car rhss)) - (parse `(begin ,body)))] + (parse `(begin ,@body)))] [else (error 'parse-let "not supported yet")]))) @@ -193,4 +195,4 @@ ;; let -> (listof expr) (define (let-body exp) - (caddr exp)) \ No newline at end of file + (cddr exp)) \ No newline at end of file diff --git a/test-compiler.rkt b/test-compiler.rkt index 9ec9e74..bf47b8d 100644 --- a/test-compiler.rkt +++ b/test-compiler.rkt @@ -482,13 +482,27 @@ (sum-integers 1 10))) (list 3025 55)) +(test (let () 5) 5) (test (let* ([x 3] [y 4] [z 17]) (+ x y z)) - 24 + 24) + + +(test (list (let* ([x 3] + [y (+ x 1)] + [z (+ x y)]) + (list x y z)) + (let* ([x 17] + [y (+ x 1)] + [z (+ x y)]) + (list x y z))) + (list (list 3 4 7) + (list 17 18 35)) #:debug? #t) + ;(simulate (compile (parse '42) 'val 'next))