>From 3b5a2237b71955638f25371005d7cbd2c4a35865 Mon Sep 17 00:00:00 2001 From: megane Date: Sat, 1 Dec 2018 10:24:16 +0200 Subject: [PATCH 1/2] Fix renaming issue with 'the' The 'the' macro calls check-and-validate-type which will eventually call simplify-type on the type. simplify-type renames type variables with gensym and sets the ##core#real-name property, perhaps because of prettier messages for the user. Finally the 'the' macro expander uses the property to undo the renaming. Fixes #1563. * scrutinizer.scm (simplify-type): Don't set the ##core#real-name property for renamed tvs * tests/typematch-tests.scm: Add test * tests/scrutiny.expected: Update Signed-off-by: Evan Hanson --- scrutinizer.scm | 4 +--- tests/scrutiny.expected | 2 +- tests/typematch-tests.scm | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/scrutinizer.scm b/scrutinizer.scm index 840cda3d..a8c8b3de 100644 --- a/scrutinizer.scm +++ b/scrutinizer.scm @@ -1224,9 +1224,7 @@ (set! typeenv (append (map (lambda (v) (let ((v (if (symbol? v) v (first v)))) - (let ((v* (gensym v))) - (mark-variable v* '##core#real-name v) - (cons v v*)))) + (cons v (gensym v)))) typevars) typeenv)) (set! constraints diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected index 665d7008..e445ebbb 100644 --- a/tests/scrutiny.expected +++ b/tests/scrutiny.expected @@ -40,7 +40,7 @@ Warning: at toplevel: (scrutiny-tests.scm:29) in procedure call to `scheme#+', expected argument #2 of type `number' but was given an argument of type `symbol' Warning: at toplevel: - assignment of value of type `fixnum' to toplevel variable `scheme#car' does not match declared type `(forall (a) (procedure scheme#car ((pair a *)) a))' + assignment of value of type `fixnum' to toplevel variable `scheme#car' does not match declared type `(forall (a335) (procedure scheme#car ((pair a335 *)) a335))' Warning: at toplevel: expected a single result in `let' binding of `g19', but received 2 results diff --git a/tests/typematch-tests.scm b/tests/typematch-tests.scm index 821ef731..231207f2 100644 --- a/tests/typematch-tests.scm +++ b/tests/typematch-tests.scm @@ -403,6 +403,9 @@ ;; The tv "foo" and "foo" in struct should have no relation ((forall (foo) (list (struct foo) foo)) 'ok)) +;; Issue #1563 +(compiler-typecase (the (forall (a) a) 1) ((forall (a) (list a)) 'ok)) + (assert (compiler-typecase 1 ('a #t))) -- 2.11.0