Fix #:methods regression at top-level

Please merge to v5.3.4
(cherry picked from commit fa80c53115)
This commit is contained in:
Asumu Takikawa 2013-04-12 15:32:05 -04:00 committed by Ryan Culpepper
parent 2001098046
commit fc75ff426a
3 changed files with 28 additions and 2 deletions

View File

@ -319,7 +319,12 @@
(raise-syntax-error #f
"not a name for a generics group"
gen:foo gen:foo))
(unless (and (identifier? gen:foo) (identifier-binding gen:foo))
(unless (and (identifier? gen:foo)
;; at the top-level, it's not possible to check
;; if this `gen:foo` is bound, so we give up on the
;; error message in that case
(or (eq? (syntax-local-context) 'top-level)
(identifier-binding gen:foo)))
(bad-generics))
(define gen:foo-val (syntax-local-value gen:foo))
(unless (and (list? gen:foo-val)

View File

@ -15,4 +15,5 @@
"contract.rkt"
"from-unstable.rkt"
"poly-contracts.rkt"
"empty-interface.rkt")
"empty-interface.rkt"
"top-level.rkt")

View File

@ -0,0 +1,20 @@
#lang racket/base
;; check that generics work at the top-level
(require racket/generic
rackunit)
(define ns (make-base-namespace))
(check-not-exn
(λ ()
(eval '(require racket/generic) ns)
(eval '(define-generics foobar [foo foobar a1]) ns)
(eval '(struct inst ()
;; make sure `gen:foobar` doesn't cause an
;; error here
#:methods gen:foobar
[(define (foo foobar a1) 0)])
ns)))