fix a bug in is-a?
This bug has been in is-a? since at least 5.2; it turns some errors into #f. Hopefully no code is actually relying on this bad behavior...
This commit is contained in:
parent
145f8711c8
commit
a931153553
|
@ -4651,9 +4651,8 @@ An example
|
|||
|
||||
(define (is-a? v c)
|
||||
(cond
|
||||
[(not (object? v)) #f]
|
||||
[(class? c) ((class-object? (class-orig-cls c)) v)]
|
||||
[(interface? c) (implementation? (object-ref v) c)]
|
||||
[(class? c) (and (object? v) ((class-object? (class-orig-cls c)) v))]
|
||||
[(interface? c) (and (object? v) (implementation? (object-ref v) c))]
|
||||
[else (raise-argument-error 'is-a? "(or/c class? interface?)" 1 v c)]))
|
||||
|
||||
(define (subclass? v c)
|
||||
|
|
|
@ -436,6 +436,10 @@
|
|||
(test #t is-a? picky (class->interface picky-fish%))
|
||||
(test #f is-a? red-fish (class->interface picky-fish%))
|
||||
|
||||
(err/rt-test (is-a? 1 2) exn:fail?)
|
||||
(err/rt-test (is-a? red-fish 2) exn:fail?)
|
||||
(test #f is-a? 11 eater<%>)
|
||||
|
||||
(err/rt-test (instantiate fish% () (bad-size 10)) exn:fail:object?)
|
||||
(err/rt-test (instantiate fish% () (size 10) (size 12)) exn:fail:object?)
|
||||
(err/rt-test (instantiate fish% (10) (size 12)) exn:fail:object?)
|
||||
|
|
Loading…
Reference in New Issue
Block a user