Skip to content

Commit

Permalink
contract check on add-global-reference-compiler!
Browse files Browse the repository at this point in the history
  • Loading branch information
quasarbright committed Oct 26, 2024
1 parent 2988c1e commit cdbf9b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions private/runtime/compile.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
; NOTE: this should never be called in the dynamic extent of a with-reference-compilers,
; or generally within a parameterization of current-reference-compilers, since it mutates the parameter.
(define (add-global-reference-compiler! bclass compiler)
(check 'binding-class (disjoin procedure? set!-transformer?)
#:contract "(or/c (-> syntax? syntax?) set!-transformer?)"
compiler)
(current-reference-compilers (free-id-table-set (current-reference-compilers) bclass compiler))))

(define-syntax with-reference-compilers
Expand Down
7 changes: 7 additions & 0 deletions tests/global-reference-compiler.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,10 @@
(lambda ()
(convert-compile-time-error
(my-let ([x 2]) (set! x 3) x))))

(check-decl-error
#rx"contract violation"
(syntax-spec
(binding-class dsl-var #:reference-compiler 2)
(nonterminal expr
[x:dsl-var x:dsl-var])))

0 comments on commit cdbf9b1

Please sign in to comment.