Adjust type variable syntax for typed classes
This makes it consistent with other forms like the new `lambda` form.
This commit is contained in:
parent
315034bbe5
commit
8ce376f503
|
@ -50,8 +50,8 @@ library.
|
|||
expr
|
||||
(begin class-clause ...)]
|
||||
[maybe-type-parameters (code:line)
|
||||
(code:line #:forall type-variable)
|
||||
(code:line #:forall (type-variable ...))]
|
||||
(code:line #:forall (type-variable ...))
|
||||
(code:line #:∀ (type-variable ...))]
|
||||
[init-decl id/type
|
||||
[renamed]
|
||||
[renamed : type-expr]
|
||||
|
|
|
@ -123,9 +123,7 @@
|
|||
(:))
|
||||
|
||||
(define-splicing-syntax-class maybe-type-parameter
|
||||
(pattern (~seq #:forall type-variable:id)
|
||||
#:attr type-variables #'(type-variable))
|
||||
(pattern (~seq #:forall (type-variable:id ...))
|
||||
(pattern (~seq (~or #:∀ #:forall) (type-variable:id ...))
|
||||
#:attr type-variables #'(type-variable ...))
|
||||
(pattern (~seq)
|
||||
#:attr type-variables #'()))
|
||||
|
|
|
@ -3322,7 +3322,7 @@
|
|||
[tc-e (let ()
|
||||
(define point%
|
||||
(class object%
|
||||
#:forall X
|
||||
#:∀ (X)
|
||||
(super-new)
|
||||
(init-field [x : X] [y : X])))
|
||||
(new (inst point% Integer) [x 0] [y 5])
|
||||
|
@ -3359,13 +3359,13 @@
|
|||
#:msg #rx"expected: X.*given: String"]
|
||||
;; fails because default init value cannot be polymorphic
|
||||
[tc-err (class object%
|
||||
#:forall Z
|
||||
#:forall (Z)
|
||||
(super-new)
|
||||
(init-field [x : Z] [y : Z 0]))
|
||||
#:msg #rx"Default init value has wrong type"]
|
||||
;; fails because default field value cannot be polymorphic
|
||||
[tc-err (class object%
|
||||
#:forall Z
|
||||
#:forall (Z)
|
||||
(super-new)
|
||||
(field [x : Z "a"]))
|
||||
#:msg #rx"expected: Z.*given: String"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user