diff --git a/tapl/tests/mlish/listpats.mlish b/tapl/tests/mlish/listpats.mlish index a68e3b6..2b66781 100644 --- a/tapl/tests/mlish/listpats.mlish +++ b/tapl/tests/mlish/listpats.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") ;; pattern matching for built-in lists diff --git a/tapl/tests/mlish/loop.mlish b/tapl/tests/mlish/loop.mlish index 7392832..c53b5ed 100644 --- a/tapl/tests/mlish/loop.mlish +++ b/tapl/tests/mlish/loop.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") ;; datatype with no self-reference diff --git a/tapl/tests/mlish/match2.mlish b/tapl/tests/mlish/match2.mlish index 49de5f9..fae4411 100644 --- a/tapl/tests/mlish/match2.mlish +++ b/tapl/tests/mlish/match2.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") ;; alternate match that supports nested patterns @@ -17,14 +17,14 @@ (match2 (B (tup 2 3)) with [A x -> x] [C (x,y) -> y] - [B x -> x]) #:with-msg "branches have incompatible types: \\(× Int Int\\) and Int") + [B x -> x]) #:with-msg "branches have incompatible types: Int and \\(× Int Int\\)") (typecheck-fail (match2 (B (tup 2 3)) with [A x -> (tup x x)] [C x -> x] [B x -> x]) - #:with-msg "branches have incompatible types: \\(× Int \\(× Int Int\\)\\) and \\(× Int Int\\)") + #:with-msg "branches have incompatible types: \\(× Int Int\\) and \\(× Int \\(× Int Int\\)\\)") (check-type (match2 (B (tup 2 3)) with @@ -241,7 +241,7 @@ (match2 (list (list #t #f)) with [nil -> -1] [(list x y) :: tl -> (+ x y)]) - #:with-msg "Type error applying function \\+") + #:with-msg "expected: Int\n *given: Bool") ;; comma tup pattern syntax diff --git a/tapl/tests/mlish/polyrecur.mlish b/tapl/tests/mlish/polyrecur.mlish index 8854b72..bbcaece 100644 --- a/tapl/tests/mlish/polyrecur.mlish +++ b/tapl/tests/mlish/polyrecur.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") ;; tests of polymorphic recursion diff --git a/tapl/tests/mlish/queens.mlish b/tapl/tests/mlish/queens.mlish index d45b4b4..cd42835 100644 --- a/tapl/tests/mlish/queens.mlish +++ b/tapl/tests/mlish/queens.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") ;; function polymorphic in list element diff --git a/tapl/tests/mlish/value-restriction-example.mlish b/tapl/tests/mlish/value-restriction-example.mlish index dd00d5c..04a08d9 100644 --- a/tapl/tests/mlish/value-restriction-example.mlish +++ b/tapl/tests/mlish/value-restriction-example.mlish @@ -1,4 +1,4 @@ -#lang s-exp "../../mlish.rkt" +#lang s-exp "../../typed-lang-builder/mlish-core.rkt" (require "../rackunit-typechecking.rkt") (define-type (Option X) diff --git a/tapl/typed-lang-builder/mlish-core.rkt b/tapl/typed-lang-builder/mlish-core.rkt index 1656440..8fc67ed 100644 --- a/tapl/typed-lang-builder/mlish-core.rkt +++ b/tapl/typed-lang-builder/mlish-core.rkt @@ -756,6 +756,7 @@ [(match e with . clauses) ▶ [#:fail-unless (not (null? (syntax->list #'clauses))) "no clauses"] [⊢ [[e ≫ e-] ⇒ : τ_e]] + [#:when (and (not (×? #'τ_e)) (not (List? #'τ_e)))] [#:with t_expect (get-expected-type stx)] ; propagate inferred type [#:with ([Clause:id x:id ... (~optional (~seq #:when e_guard) #:defaults ([e_guard #'(ext-stlc:#%datum . #t)]))