Relax parsing of All types and type annotations

Closes PR 14839
This commit is contained in:
Asumu Takikawa 2014-11-18 13:54:39 -05:00
parent 04be65f781
commit 27132ee061
5 changed files with 36 additions and 4 deletions

View File

@ -32,8 +32,6 @@
[(: id (~and kw :) . more:omit-parens)
(add-disappeared-use #'kw)
(wrap stx #`(:-helper #,stx #,top-level? id more.type))]
[(: id : . more)
(wrap stx #`(:-helper #,stx #,top-level? id . more))]
[(: e ...)
(wrap stx #`(:-helper #,stx #,top-level? e ...))]))

View File

@ -38,5 +38,5 @@
;; or with #:fail-when. -- AT
(pattern (~and (:->^ x y ~! z ...) (~fail))
#:with type 'dummy)
(pattern (~and type ((~or (~once :->^) (~not :->^)) ...)))
(pattern (~and type ((~or (~between :->^ 1 +inf.0) (~not :->^)) ...)))
(pattern (type)))

View File

@ -41,4 +41,5 @@
"filter-tests.rkt"
"metafunction-tests.rkt"
"generalize-tests.rkt"
"rep-tests.rkt")
"rep-tests.rkt"
"prims-tests.rkt")

View File

@ -99,7 +99,11 @@
[(-> (values Number Boolean Number)) (t:-> (-values (list N B N)))]
[(Number -> Number) (t:-> N N)]
[(All (A) Number -> Number) (-poly (a) (t:-> N N))]
[(All (A) Number -> Number -> Number) (-poly (a) (t:-> N (t:-> N N)))]
[(All (A) Number -> Number -> Number -> Number)
(-poly (a) (t:-> N (t:-> N (t:-> N N))))]
[FAIL (All (A) -> Number Number)]
[FAIL (All (A) Listof Any)]
[(All (A) (Number -> Number)) (-poly (a) (t:-> N N))]
[(All (A) (-> Number Number)) (-poly (a) (t:-> N N))]
[(All (A) A -> A) (-poly (a) (t:-> a a))]

View File

@ -0,0 +1,29 @@
#lang racket/base
;; Tests for Typed Racket primitive macros
(require "test-utils.rkt"
(base-env base-types-extra)
(base-env prims)
rackunit
unstable/macro-testing)
(provide tests)
(gen-test-main)
(define-syntax-rule (check-ok exp)
(check-not-exn (λ () (convert-compile-time-error exp))))
(define-syntax-rule (check-bad exp regex)
(check-exn regex (λ () (convert-compile-time-error exp))))
;; These tests don't run the type-checker, they just correct expansion
;; and error checking in primitive macros
(define tests
(test-suite "Prims tests"
(check-bad (let () (: x : Listof Any) 'dummy)
#rx"multiple types")
(check-bad (let () (: x : -> String String) 'dummy)
#rx"multiple types")
(check-ok (let () (: x : String -> String -> String)
(define x 0)
'dummy))))