Below, I think `(func 42)` should raise exn:fail:contract, because `(func 42)` 
returns a number and the output contract for `func` specifies a boolean. 

And in 6.0 it does raise this error. But in 6.1 and 6.2, it does not. Why the 
discrepancy?

;;;;;;;;;;;;;;;;;;;;

#lang racket

(provide (contract-out [func ((any/c) (#:kw any/c) . ->* . boolean?)]))
(define (func x #:kw [kw 0])
  x)

(module* star racket/base
  (require (submod ".."))
  (require rackunit)
  (check-exn exn:fail:contract? (λ _ (func 42) 42))) ; no exn raised in 6.1 or 
6.2

(module+ test
  (require (submod ".." star)))

;;;;;;;;;;;;;;;;;;;;;


BTW two conditions seem mandatory to reproduce the odd behavior: 1) the 
presence of one positional and one keyword argument, and 2) at least one 
argument is optional. 

For instance, this modification with no optional argument will raise the 
correct error in 6.0, 6.1, and 6.2:


;;;;;;;;;;;;;;;;;;;;;

#lang racket

(provide (contract-out [func (any/c #:kw any/c . -> . boolean?)]))
(define (func x #:kw kw)
  x)

(module* star racket/base
  (require (submod ".."))
  (require rackunit)
  (check-exn exn:fail:contract? (λ _ (func 42 #:kw 0) 42))) ; works in 6.0, 
6.1, 6.2

(module+ test
  (require (submod ".." star)))

;;;;;;;;;;;;;;;;;;;;

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to