diff --git a/pkgs/racket-test-core/tests/racket/foreign-test.rktl b/pkgs/racket-test-core/tests/racket/foreign-test.rktl index 64a6cf7dc3..27ab1895d5 100644 --- a/pkgs/racket-test-core/tests/racket/foreign-test.rktl +++ b/pkgs/racket-test-core/tests/racket/foreign-test.rktl @@ -151,6 +151,9 @@ ;; Make sure `_box` at least compiles: (test #t ctype? (_fun (_box _int) -> _void)) +;; Make sure that _enum works in non first order cases +(test #t ctype? (let ([enum _enum]) (enum '(x y)))) + (define-cstruct _ic7i ([i1 _int] [c7 _c7_list] [i2 _int])) diff --git a/racket/collects/ffi/unsafe.rkt b/racket/collects/ffi/unsafe.rkt index 8dc39e81f3..f0922fb83d 100644 --- a/racket/collects/ffi/unsafe.rkt +++ b/racket/collects/ffi/unsafe.rkt @@ -794,9 +794,9 @@ ;; ---------------------------------------------------------------------------- ;; Utility types -;; Call this with a name (symbol) and a list of symbols, where a symbol can be +;; Call this with a name (symbol or #f) and a list of symbols, where a symbol can be ;; followed by a '= and an integer to have a similar effect of C's enum. -(define (_enum name symbols [basetype _ufixint] #:unknown [unknown _enum]) +(define ((_enum name) symbols [basetype _ufixint] #:unknown [unknown _enum]) (define sym->int '()) (define int->sym '()) (define s->c @@ -832,8 +832,8 @@ (define-syntax (_enum* stx) (syntax-case stx () [(_ x ...) - (with-syntax ([name (syntax-local-name)]) #'(_enum 'name x ...))] - [id (identifier? #'id) #'_enum])) + (with-syntax ([name (syntax-local-name)]) #'((_enum 'name) x ...))] + [id (identifier? #'id) #'(_enum #f)])) ;; Call this with a name (symbol) and a list of (symbol int) or symbols like ;; the above with '= -- but the numbers have to be specified in some way. The