Skip to content

Commit 925c5e7

Browse files
authored
Don't refactor quasiquotes with only literals (#474)
Closes #425.
1 parent 9a30ca0 commit 925c5e7

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

default-recommendations/list-shortcuts-test.rkt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ test: "unnecessary quasiquotation with constants refactorable to list"
139139
------------------------------
140140

141141

142+
test: "quasiquotation with only constants not refactorable to list"
143+
- `(1 2 3)
144+
145+
142146
test: "unnecessary splicing quasiquotation refactorable to append"
143147
------------------------------
144148
(define (f xs ys zs)

default-recommendations/list-shortcuts.rkt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,18 @@
106106

107107

108108
(define-syntax-class unquoted
109-
#:attributes (expr)
109+
#:attributes (expr literal?)
110110
#:literals (unquote)
111-
(pattern expr:literal-constant)
112-
(pattern (unquote expr)))
111+
(pattern expr:literal-constant #:attr literal? #true)
112+
(pattern (unquote expr) #:attr literal? #false))
113113

114114

115115
(define-refactoring-rule quasiquote-to-list
116116
#:description "This quasiquotation is equialent to a simple `list` call."
117117
#:literals (quasiquote)
118118
(quasiquote (arg:unquoted ...))
119+
#:when (for/or ([literal? (in-list (attribute arg.literal?))])
120+
(not literal?))
119121
(list arg.expr ...))
120122

121123

0 commit comments

Comments
 (0)