From 4a44e51b80aa7b79f0f28483778e512ec9c110dc Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 18 Mar 2016 17:11:47 -0400 Subject: [PATCH] fix bug using expected type of id constructors, eg nil --- tapl/mlish.rkt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt index 01d2ab1..6590196 100644 --- a/tapl/mlish.rkt +++ b/tapl/mlish.rkt @@ -226,9 +226,9 @@ #:with τ-expected (syntax-property #'C 'expected-type) #:fail-unless (syntax-e #'τ-expected) (type-error #:src stx #:msg "cannot infer type of ~a; add annotations" #'C) - #:with (NameExpander τ-expected-arg (... ...)) #'τ-expected + #:with (NameExpander τ-expected-arg (... ...)) ((current-type-eval) #'τ-expected) #'(C {τ-expected-arg (... ...)})] - [_:id + [_:id #:when (and (not (stx-null? #'(X ...))) (not (stx-null? #'(τ ...)))) (type-error @@ -782,6 +782,7 @@ (⊢ (hash-count h-) : Int)]) (define-base-type String-Port) +(define-base-type Input-Port) (define-primop open-output-string : (→ String-Port)) (define-primop get-output-string : (→ String-Port String)) (define-primop string-upcase : (→ String String)) @@ -879,3 +880,10 @@ #'(∀ () ty_e) #'ty_e) (⊢ e- : ty_out)])) + +(define-typed-syntax read + [(_) + (⊢ (let ([x (read)]) + (cond [(eof-object? x) ""] + [(number? x) (number->string x)] + [(symbol? x) (symbol->string x)])) : String)])