From c89aa1be195b85317ac79845c06586be06c6921f Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Fri, 18 Mar 2016 11:57:46 -0400 Subject: [PATCH] fix expected-ty propagation in cond else; closes #3 --- tapl/mlish.rkt | 2 +- tapl/tests/mlish/inst.mlish | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tapl/mlish.rkt b/tapl/mlish.rkt index 508d515..18ee4ae 100644 --- a/tapl/mlish.rkt +++ b/tapl/mlish.rkt @@ -482,7 +482,7 @@ #:when (same-types? #'(ty_body ...)) #:with τ_out (stx-car #'(ty_body ...)) #:with [last-body- last-ty] (if (attribute else_body) - (infer+erase #'else_body) + (infer+erase #'(add-expected else_body ty-expected)) (infer+erase #'(void))) #:with ([last-b- last-b-ty] ...) (if (attribute else_body) (infers+erase #'(else_b ...)) diff --git a/tapl/tests/mlish/inst.mlish b/tapl/tests/mlish/inst.mlish index 21ff08c..f507370 100644 --- a/tapl/tests/mlish/inst.mlish +++ b/tapl/tests/mlish/inst.mlish @@ -32,3 +32,7 @@ (h)) (check-type i : (→/test (Result Int String))) + +(define (f/cond [b : Bool] -> (Result Int String)) + (cond [b (ok 1)] + [else (ok 0)]))