@@ -43,18 +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))
4849 ;; Check that all ~a occurrences are surrounded by spaces or at string boundaries
49- #:when (let ([matches (regexp-match-positions* #rx"~a " message-str)])
50- (for/and ([match (in-list 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?)))
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?))
5858 #:do [(define cleaned-message (string-replace message-str "~a " "" ))
5959 ;; Clean up extra spaces and trailing punctuation from placeholder removal
6060 (define cleaned-message-normalized
0 commit comments