From dc3ef29b18717ed5d3d49ca9589ed3ec17d24847 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Mon, 7 Apr 2014 14:42:37 -0400 Subject: [PATCH] Catch #:row-var parsing problems in TR Closes PR 14434 original commit: e692edc180be26c92726dffd1a595d4db3e25560 --- .../typed-racket/private/parse-type.rkt | 18 ++++++++++++++---- .../unit-tests/parse-type-tests.rkt | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt index d2818a76..42194985 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/parse-type.rkt @@ -704,10 +704,20 @@ (and (attribute clause.init-rest) (parse-type (attribute clause.init-rest)))) - ;; Only proceed to create a class type when the parsing - ;; process isn't looking for recursive type alias references. - ;; (otherwise the merging process will error) - (cond [(or (null? parent-stxs) + (cond ;; If an Error type flows into the #:row-var position, a + ;; delayed error should be raised from the recursive call to + ;; `parse-type` so no additional error is needed here. + [(Error? given-row-var) Err] + [(not (F? given-row-var)) + (tc-error/fields "parse error in type" + #:more "expected a type variable for #:row-var" + "given" given-row-var + #:delayed? #t) + Err] + ;; Only proceed to create a class type when the parsing + ;; process isn't looking for recursive type alias references. + ;; (otherwise the merging process will error) + [(or (null? parent-stxs) (not (current-referenced-aliases))) (check-function-types given-methods) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/parse-type-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/parse-type-tests.rkt index a438d808..5ef89958 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/parse-type-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/parse-type-tests.rkt @@ -242,6 +242,7 @@ [FAIL (All (r #:row) (Class #:implements (Class) #:row-var r))] [FAIL (Class #:row-var 5)] [FAIL (Class #:row-var (list 3))] + [FAIL (Class #:row-var x)] [FAIL (Class #:implements (Class #:row-var r) #:row-var x)] [FAIL (Class #:implements (Class #:row-var r) #:row-var r)] [FAIL (All (r #:row)