Skip to content

Commit 9580e5e

Browse files
Copilotjackfirth
andcommitted
Fix let expression result-form handling and add missing require
Co-authored-by: jackfirth <[email protected]>
1 parent 582ccbd commit 9580e5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

default-recommendations/loops/fuse-map-with-for.rkt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
(require resyntax/base
13+
racket/list
1314
resyntax/default-recommendations/analyzers/identifier-usage
1415
resyntax/default-recommendations/let-replacement/private/let-binding
1516
resyntax/default-recommendations/private/lambda-by-any-name
@@ -29,8 +30,11 @@
2930
(_:lambda-by-any-name (x:id)
3031
original-body:body-with-refactorable-let-expression)
3132
#:with (multi-body ...) #'(original-body.refactored ...)
32-
#:attr [prefix-forms 1] (attribute original-body.refactored)
33-
#:attr result-form #'(begin)
33+
#:do [(define refactored-forms (attribute original-body.refactored))
34+
(define prefix-list (if (null? refactored-forms) '() (drop-right refactored-forms 1)))
35+
(define result (if (null? refactored-forms) #'(begin) (last refactored-forms)))]
36+
#:attr [prefix-forms 1] prefix-list
37+
#:attr result-form result
3438
#:attr single-body #'(begin original-body.refactored ...))
3539

3640
;; Lambdas with multiple body forms (two or more)

0 commit comments

Comments
 (0)