Re: [Chicken-hackers] [PATCH] Fix #1470 and unignore clean/pure declarations

2019-08-26 Thread Evan Hanson
Makes sense to me, applied.

This should improve scrutiny when running csc with the default options, too.

Cheers,

Evan

___
Chicken-hackers mailing list
Chicken-hackers@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-hackers


[Chicken-hackers] [PATCH] Fix #1470 and unignore clean/pure declarations

2019-08-25 Thread Peter Bex
Hi all,

I was looking through our ticket tracker and encountered #1470.
It looks like the specific test case mentioned there does not exist
anymore, but I decided it's a good idea regardless.

While doing that, I noticed that when running with -specialize, I got
slightly different output for predicates.  For example, the reported
type of string? is (* --> boolean) instead of (* -> boolean) as in the
"expected" file.  I checked the code, and when loading types database
files, we skip marking variables as #:pure or #:clean unless we're
specializing.  I asked Felix and he agreed that this seems incorrect.

So the attached patch consists of two changes; the first ensures we
always honour these annotations when loading types databases, the second
enables -specialize for the scrutiny tests as suggested by #1470.

Cheers,
Peter
From b8cb0cedac1390d43b17f2a5f8e28b868bdb3e38 Mon Sep 17 00:00:00 2001
From: Peter Bex 
Date: Sun, 25 Aug 2019 12:06:05 +0200
Subject: [PATCH 1/2] Also load "clean" and "pure" annotations from types.db
 when not specializing

There seems to be no good reason for skipping just these two when
loading types databases.  All the other places that mark things as
pure or clean do it unconditionally, too.
---
 scrutinizer.scm   |  8 ++--
 tests/scrutiny-2.expected |  2 +-
 tests/scrutiny.expected   | 12 ++--
 3 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/scrutinizer.scm b/scrutinizer.scm
index 8f5923d5..47b7c0d3 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -1587,10 +1587,6 @@
 
 (define (load-type-database name specialize #!optional
 (path (repository-path)))
-  (define (clean! name)
-(when specialize (mark-variable name '##compiler#clean #t)))
-  (define (pure! name)
-(when specialize (mark-variable name '##compiler#pure #t)))
   (and-let* ((dbfile (if (not path)
 			 (and (##sys#file-exists? name #t #f #f) name)
 			 (chicken.load#find-file name path
@@ -1610,10 +1606,10 @@
 (unless (null? props)
   (case (car props)
 ((#:pure)
- (pure! name)
+ (mark-variable name '##compiler#pure #t)
  (loop (cdr props)))
 ((#:clean)
- (clean! name)
+ (mark-variable name '##compiler#clean #t)
  (loop (cdr props)))
 ((#:enforce)
  (mark-variable name '##compiler#enforce #t)
diff --git a/tests/scrutiny-2.expected b/tests/scrutiny-2.expected
index 44315153..cd406985 100644
--- a/tests/scrutiny-2.expected
+++ b/tests/scrutiny-2.expected
@@ -16,7 +16,7 @@ Note: Predicate is always true
 
   The given argument has this type:
 
-pair
+(pair fixnum fixnum)
 
 Note: Predicate is always false
   In file `scrutiny-tests-2.scm:XXX',
diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
index 2396a539..b93f9d23 100644
--- a/tests/scrutiny.expected
+++ b/tests/scrutiny.expected
@@ -76,7 +76,7 @@ Warning: Wrong number of arguments
 
   Procedure `string?' from module `scheme' has this type:
 
-(* -> boolean)
+(* --> boolean)
 
 Warning: Too many argument values
   In file `scrutiny-tests.scm:XXX',
@@ -556,7 +556,7 @@ Warning: Invalid argument
 
   It is a call to `list' from module `scheme' which has this type:
 
-(#!rest * -> list)
+(#!rest * --> list)
 
   This is the expression:
 
@@ -583,7 +583,7 @@ Warning: Invalid argument
 
   It is a call to `cons' from module `scheme' which has this type:
 
-('a 'b -> (pair 'a 'b))
+('a 'b --> (pair 'a 'b))
 
   This is the expression:
 
@@ -780,7 +780,7 @@ Warning: Invalid argument
 
   It is a call to `list' from module `scheme' which has this type:
 
-(#!rest * -> list)
+(#!rest * --> list)
 
   This is the expression:
 
@@ -807,7 +807,7 @@ Warning: Invalid argument
 
   It is a call to `list' from module `scheme' which has this type:
 
-(#!rest * -> list)
+(#!rest * --> list)
 
   This is the expression:
 
@@ -834,7 +834,7 @@ Warning: Invalid argument
 
   It is a call to `cons' from module `scheme' which has this type:
 
-('a 'b -> (pair 'a 'b))
+('a 'b --> (pair 'a 'b))
 
   This is the expression:
 
-- 
2.20.1

From add4c026ad10b5311c5699e3412e5d8dbdbb8129 Mon Sep 17 00:00:00 2001
From: Peter Bex 
Date: Sun, 25 Aug 2019 12:16:16 +0200
Subject: [PATCH 2/2] Run scrutiny tests with -specialize

There used to be cases where you'd get errors when specializing but
not when just analyzing.

Fixes #1470 (the test in question is gone now, though)
---
 tests/runtests.sh |   8 +-
 tests/scrutiny-2.expected | 355 +-
 tests/scrutiny.expected   |  16 +-
 3 files changed, 361 insertions(+), 18 deletions(-)

diff --git a/tests/runtests.sh b/tests/runtests.sh
index 1811cc35..2c85d71c 100755
--- a/tests/runtests.sh
+++ b/tests/runtests.sh
@@ -113,10 +113,10 @@ $compile scrutinizer-tests.scm -analyze-only
 $compile typematch-tests.scm -specialize -no-warnings
 ./a.out
 
-$compile