File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -153,3 +153,18 @@ test: "error with ~a at end of string"
153153(define (end-tilde x)
154154 (raise-arguments-error 'end-tilde "value is " "x " x))
155155--------------------
156+
157+
158+ no-change-test: "error with ~a in quotes should not be refactored "
159+ --------------------
160+ (define (find-output-radio-box label)
161+ (error 'find-output-radio-box "could not find `~a' radio box "
162+ label))
163+ --------------------
164+
165+
166+ no-change-test: "error with ~a in parentheses should not be refactored "
167+ --------------------
168+ (define (f x y)
169+ (error 'f "bad point (~a, ~a) " x y))
170+ --------------------
Original file line number Diff line number Diff line change @@ -43,8 +43,18 @@ conventions."
4343 (error sym:expr message:str arg:id ...+)
4444
4545 #:do [(define message-str (syntax-e (attribute message)))
46- (define args-list (attribute arg))]
47- #:when (= (length (regexp-match* #rx"~a " message-str)) (length args-list))
46+ (define args-list (attribute arg))
47+ (define tilde-a-matches (regexp-match-positions* #rx"~a " message-str))]
48+ #:when (= (length tilde-a-matches) (length args-list))
49+ ;; Check that all ~a occurrences are surrounded by spaces or at string boundaries
50+ #:when (for/and ([match (in-list tilde-a-matches)])
51+ (define start (car match ))
52+ (define end (cdr match ))
53+ (define before-ok? (or (= start 0 )
54+ (char-whitespace? (string-ref message-str (- start 1 )))))
55+ (define after-ok? (or (= end (string-length message-str))
56+ (char-whitespace? (string-ref message-str end))))
57+ (and before-ok? after-ok?))
4858 #:do [(define cleaned-message (string-replace message-str "~a " "" ))
4959 ;; Clean up extra spaces and trailing punctuation from placeholder removal
5060 (define cleaned-message-normalized
You can’t perform that action at this time.
0 commit comments