typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

The error message is incorrect when required keyword argument not supplied

Open NoahStoryM opened this issue 3 years ago • 2 comments

What version of Racket are you using?

v8.2

What program did you run?

#lang typed/racket

(: func (case-> [-> #:bool True  One]
                [-> #:bool False Zero]))
(define (func #:bool b)
  (cond [(eq? #t b) 1]
        [(eq? #f b) 0]))

(func)

What should have happened?

The correct error message should look like this:

Type Checker: could not apply function;
 a required keyword was not supplied
  missing keyword: ...

If you got an error message, please include it here.

define/match: no matching clause for (list #<void> Top)
  location...:
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/types/prop-ops.rkt:408:0
  context...:
   .../match/define-forms.rkt:201:11: add-unconditional-prop
   .../private/runtime.rkt:80:24: temp699
   .../private/runtime.rkt:89:23: fail-handler118
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-expr-unit.rkt:112:0: tc-expr/check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:391:0: type-check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:635:0: tc-module
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:101:12
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:22:4

NoahStoryM avatar Nov 03 '21 12:11 NoahStoryM

What version of Racket are you using?

v8.2

What program did you run?

#lang typed/racket


(: func [-> #:bool Boolean Any])
(define (func #:bool b)
  (cond [(eq? b #t) 1]
        [(eq? b #f) 0]))

(apply func '())

What should have happened?

In untyped version, the error message is:

application: required keyword argument not supplied
  procedure: func
  required keyword: #:bool

If you got an error message, please include it here.

draft1.rkt:9:0: Type Checker: Type of argument to apply is not a function type: 
(-> #:bool Boolean Any)
  in: (apply func (quote ()))
  location...:
   draft1.rkt:9:0
  context...:
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:391:0: type-check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:635:0: tc-module
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:101:12
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:22:4

NoahStoryM avatar Nov 04 '21 02:11 NoahStoryM

I'm not sure if I missed something or Typed Racket doesn't support using keywords to apply function:

What version of Racket are you using?

v8.2

What program did you run?

#lang typed/racket

(: func [-> [#:bool True] One])
(define (func #:bool [b #t]) 1)

(apply func #:bool #t '())

What should have happened?

1

If you got an error message, please include it here.

draft1.rkt:6:0: Type Checker: Inference for polymorphic keyword functions not supported
  in: (apply func #:bool #t (quote ()))
  location...:
   draft1.rkt:6:0
  context...:
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:391:0: type-check
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typecheck/tc-toplevel.rkt:635:0: tc-module
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:101:12
   /usr/share/racket/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:22:4

NoahStoryM avatar Nov 04 '21 02:11 NoahStoryM