commit b8e3ad16024a693c632383bd478c2e01ad07ad71 parent db1da5ae20f223d7f02991039d9cfd1f11b38301 Author: Stephen Chang <stchang@ccs.neu.edu> Date: Thu, 10 Mar 2016 16:14:36 -0500 fix bug with tyvar computation - define separate ->/test constructor that computes tyvars and -> does not because it may be nested (see "try" fn in alex.mlish) - add alex.mlish tests - other mlish tests still broken --- need to use ->/text Diffstat:
| M | tapl/mlish.rkt | | | 11 | ++++++----- |
| A | tapl/tests/mlish/alex.mlish | | | 11 | +++++++++++ |
| M | tapl/tests/run-all-mlish-tests.rkt | | | 1 | + |
3 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt @@ -333,11 +333,12 @@ (define-syntax → ; wrapping → (syntax-parser - #;[(_ (~and Xs {X:id ...}) . rst) - #:when (brace? #'Xs) - #:when (with-handlers ([exn:fail:syntax:unbound? (λ (e) (displayln (exn:fail:syntax-exprs e)))]) - ((current-type-eval) #'(ext-stlc:→ . rst))) - #'(∀ (X ...) (ext-stlc:→ . rst))] + [(_ . rst) #'(∀ () (ext-stlc:→ . rst))])) +; special arrow that computes free vars; for use with tests +; (because we can't write explicit forall +(provide →/test) +(define-syntax →/test + (syntax-parser [(_ . rst) (let L ([Xs #'()]) ; compute unbound ids; treat as tyvars (with-handlers ([exn:fail:syntax:unbound? diff --git a/tapl/tests/mlish/alex.mlish b/tapl/tests/mlish/alex.mlish @@ -0,0 +1,11 @@ +#lang s-exp "../../mlish.rkt" +(require "../rackunit-typechecking.rkt") + +#;(define (should-err [x : X] [f : (→ X Y)] -> Y) + (let ([y (f x)]) + x)) + +(define (try [x : X][f : (→ X Y)] → X) + (let ([y (f x)]) x)) + +(check-type try : (→/test X (→ X Y) X)) diff --git a/tapl/tests/run-all-mlish-tests.rkt b/tapl/tests/run-all-mlish-tests.rkt @@ -17,3 +17,4 @@ ;; from rw ocaml (require "mlish/term.mlish") (require "mlish/find.mlish") +(require "mlish/alex.mlish")