racket/typed-racket

Better error message for misuse of row polymorphic types and add documentation for `(All (r #:row) body)`

オープン

#1,146 opened on 2021/10/05

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)Racket (106 件のフォーク)github user discovery
classgood first issue

Repository metrics

Stars
 (576 個のスター)
PR merge metrics
 (平均マージ 11d 14h) (30d で 1 merged PR)

説明

What version of Racket are you using?

Racket 8.2.0.8

What program did you run?


(: hi (All (r #:row)
           (-> r r)))
(define (hi a)
  a)

What should have happened?

The type checker should reject the program, because a type variable for a polymorphic row type is in fact only allowed to appear in (Class #:row-var _) in Typed Racket.

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

No error message. But the type checker does not produce useful error messages when hi is called, e.g.: (hi 10) ===>

Type Checker: Polymorphic function `hi' could not be applied to arguments:
Argument 1:
  Expected: r
  Given:    Positive-Byte

Result type:     r
Expected result: AnyValues

Calling hi with a class type causes an internal error (with PLT_TR_CONTRACT enabled)

(define cls1
  (class object%
    ; Note the missing `super-new`
    (init-field [x : Real 0] [y : Real 0])
    (super-new)))

(hi cls1)

===>

check-below: contract violation
  expected: (or/c Type? tc-results/c)
  given: (Row (list (list 'x Real #t) (list 'y Real #t)) (list (list 'x Real) (list 'y Real)) '() '() #f)
  in: the t argument of
      (->i
       ((s
         (t)
         (if (Type? t)
           (-or/c full-tc-results/c Type?)
           full-tc-results/c))
        (t (or/c Type? tc-results/c)))
       (_
        (t)
        (if (Type? t) Type? full-tc-results/c)))
  contract from: 
      <pkgs>/typed-racket-lib/typed-racket/typecheck/check-below.rkt
  blaming: <pkgs>/typed-racket-lib/typed-racket/typecheck/tc-app-helper.rkt
   (assuming the contract is correct)
  at: <pkgs>/typed-racket-lib/typed-racket/typecheck/check-below.rkt:20:2

lack of documentation how to define polymorphic row types

It seems the documentation for (All (r #:row) body) is missing

コントリビューターガイド