I'm playing around with the idea of a macro that can, at compile time, find syntax errors in SQL queries. I'm very new to Racket in general and so for now I'm simply trying to write a macro that won't compile if I provide a string that contains a specific substring. I can't figure out how to do this and would love some pointers:
#lang racket
(define-for-syntax (contains-secret? str)
(regexp-match? #rx"secret" str))
; How can I use contains-secret? in here?
; When I try and check `s` I get the error: s: pattern variable cannot be used outside of a template in: s
(define-syntax (foo str)
(syntax-case str ()
[(_ s) (syntax "redacted")]
[(_ _) (syntax str)]))
(foo "secret") ; Should return "redacted"
(foo "anything else") ; Should return "anything else"
I was thinking I could use fender expression but I can't get that to work.