Skip to content

Commit f1f4f2e

Browse files
Copilotjackfirth
andauthored
Fix nested-when-to-compound-when triggering on single when with and (#743)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: jackfirth <[email protected]>
1 parent 58d264b commit f1f4f2e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

default-recommendations/conditional-shortcuts-test.rkt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,15 @@ no-change-test: "when with multiple forms in outer body should not be merged"
772772
--------------------
773773

774774

775+
no-change-test: "single when with and containing 3 conditions should not be refactored"
776+
--------------------
777+
(define (f a b c)
778+
(when (and (a) (b)
779+
(c))
780+
(displayln "foo")))
781+
--------------------
782+
783+
775784
test: "ignored and expression refactorable to when expression"
776785
--------------------
777786
(define (f c1)

default-recommendations/conditional-shortcuts.rkt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@
222222
"Nested `when` expressions can be merged into a single compound `when` expression."
223223
when-expr:nested-when-expression
224224
#:when (or (>= (attribute when-expr.depth) 3)
225-
(>= (length (attribute when-expr.condition)) 3)
225+
(and (>= (attribute when-expr.depth) 2)
226+
(>= (length (attribute when-expr.condition)) 3))
226227
(and (equal? (attribute when-expr.depth) 2)
227228
(andmap identifier? (attribute when-expr.condition))))
228229
(when (and when-expr.condition ...) when-expr.body ...))

0 commit comments

Comments
 (0)