Fix TR error for missing mandatory keywords
This commit is contained in:
parent
2ac2262f00
commit
c7162ec533
11
collects/tests/typed-racket/fail/mandatory-kw.rkt
Normal file
11
collects/tests/typed-racket/fail/mandatory-kw.rkt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
#;
|
||||||
|
(exn:pred (lambda (e) (regexp-match? "Type Checker" e)))
|
||||||
|
#lang typed/racket
|
||||||
|
|
||||||
|
;; This should raise a type error and not an internal error
|
||||||
|
|
||||||
|
(: f (#:foo False -> False))
|
||||||
|
(define (f #:foo foo) foo)
|
||||||
|
|
||||||
|
;; bad call that's missing a mandatory keyword
|
||||||
|
(f)
|
|
@ -44,6 +44,18 @@
|
||||||
([r (in-list results)])
|
([r (in-list results)])
|
||||||
(open-Result r o-a t-a)))
|
(open-Result r o-a t-a)))
|
||||||
(ret t-r f-r o-r)))]
|
(ret t-r f-r o-r)))]
|
||||||
|
;; this case should only match if the function type has mandatory keywords
|
||||||
|
;; but no keywords were provided in the application
|
||||||
|
[((arr: _ _ _ _
|
||||||
|
;; at least one mandatory keyword
|
||||||
|
(app (λ (kws)
|
||||||
|
(for/or ([keyword kws])
|
||||||
|
(match keyword
|
||||||
|
[(Keyword: kw _ #t) kw]
|
||||||
|
[_ #f])))
|
||||||
|
(? values req-kw))) _)
|
||||||
|
(when check?
|
||||||
|
(tc-error "Required keyword not supplied: ~a" req-kw))]
|
||||||
[((arr: _ _ _ drest '()) _)
|
[((arr: _ _ _ drest '()) _)
|
||||||
(int-err "funapp with drest args ~a ~a NYI" drest argtys)]
|
(int-err "funapp with drest args ~a ~a NYI" drest argtys)]
|
||||||
[((arr: _ _ _ _ kws) _)
|
[((arr: _ _ _ _ kws) _)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user