File tree Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Expand file tree Collapse file tree 2 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -684,3 +684,37 @@ test: "redundant let bindings can be removed"
684684(define x 1 )
685685(* x 2 )
686686------------------------------
687+
688+
689+ test: "single-line cond clause with let should be reformatted when refactoring to define "
690+ ------------------------------
691+ (define (f x)
692+ (cond
693+ [(number? x) (let ([y 42 ]) (+ x y))]
694+ [else 'else ]))
695+ ==============================
696+ (define (f x)
697+ (cond
698+ [(number? x)
699+ (define y 42 )
700+ (+ x y)]
701+ [else 'else ]))
702+ ------------------------------
703+
704+
705+ test: "single-line match clause with let should be reformatted when refactoring to define "
706+ ------------------------------
707+ (require racket/match)
708+ (define (f x)
709+ (match x
710+ [(? number? x) (let ([y 42 ]) (+ x y))]
711+ [_ 'else ]))
712+ ==============================
713+ (require racket/match)
714+ (define (f x)
715+ (match x
716+ [(? number? x)
717+ (define y 42 )
718+ (+ x y)]
719+ [_ 'else ]))
720+ ------------------------------
Original file line number Diff line number Diff line change 1010
1111
1212(require (for-syntax racket/base)
13+ racket/list
1314 racket/set
1415 rebellion/private/static-name
1516 resyntax/base
4243 #:description
4344 "Internal definitions are recommended instead of `let` expressions, to reduce nesting. "
4445 (~seq leading-body ... let-expression:refactorable-let-expression)
45- #:with (replacement ... ) #'(~focus-replacement-on (let-expression.refactored ... ))
46+ #:with (replacement ... )
47+ (if (empty? (attribute leading-body))
48+ (attribute let-expression.refactored)
49+ #'(~focus-replacement-on (let-expression.refactored ... )))
4650 (leading-body ... replacement ... ))
4751
4852
You can’t perform that action at this time.
0 commit comments