TR: better error for invalid super-make-object

original commit: 994648c556e026df55d95bddf017b9a5ce723688
This commit is contained in:
Asumu Takikawa 2014-03-05 01:43:18 -05:00
parent f25af5b48a
commit 64515f386a
2 changed files with 10 additions and 2 deletions

View File

@ -1132,8 +1132,13 @@
(cond [;; too many init arguments, and no init-rest
(and (not super-init-rest) (> pos-length (length super-inits)))
(values super-init-rest
(tc-error/expr "too many positional init arguments provided"
#:return null))]
(tc-error/expr/fields
"invalid `super-make-object' or `super-instantiate'"
#:more "too many positional init arguments provided"
"expected" (length super-inits)
"given" pos-length
#:stx #`(#,@provided-pos-args)
#:return null))]
[;; no remaining by-name inits, so change the init-rest type
;; and return a null remaining named inits list
(> pos-length (length super-inits))

View File

@ -1245,6 +1245,9 @@
(init-rest [rst : (List Symbol)])))
(make-object c% "wrong"))
#:msg #rx"expected: Symbol.*given: String"]
;; fail, too many positional arguments to superclass
[tc-err (class object% (super-make-object "foo"))
#:msg #rx"too many positional init arguments"]
;; check that case-lambda methods work
[tc-e (let ()
(class object%