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 <pe...@more-magic.net> 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 <pe...@more-magic.net> 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 test-scrutinizer-message-format.scm -A -specialize 2>scrutinizer-message-format.out || true -$compile scrutiny-tests.scm -A 2>scrutiny.out -$compile scrutiny-tests-2.scm -A 2>scrutiny-2.out -$compile specialization-tests.scm -A -specialize 2>specialization.out +$compile test-scrutinizer-message-format.scm -analyze-only -specialize 2>scrutinizer-message-format.out || true +$compile scrutiny-tests.scm -analyze-only -specialize 2>scrutiny.out +$compile scrutiny-tests-2.scm -analyze-only -specialize 2>scrutiny-2.out +$compile specialization-tests.scm -analyze-only -specialize -specialize 2>specialization.out # Replace foo123 -> fooXX so gensyms don't trigger failures $compile redact-gensyms.scm -o redact-gensyms diff --git a/tests/scrutiny-2.expected b/tests/scrutiny-2.expected index cd406985..dc369518 100644 --- a/tests/scrutiny-2.expected +++ b/tests/scrutiny-2.expected @@ -18,6 +18,18 @@ Note: Predicate is always true (pair fixnum fixnum) +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(pair? p))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -35,6 +47,18 @@ Note: Predicate is always false null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -52,6 +76,18 @@ Note: Predicate is always false null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -69,6 +105,18 @@ Note: Predicate is always false fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -86,6 +134,18 @@ Note: Predicate is always false float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -103,6 +163,18 @@ Note: Predicate is always true null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(list? l))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -120,6 +192,47 @@ Note: Predicate is always true null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(list? n))) + + Test condition has always true value of type: + + true + +Note: Predicate is always false + In file `scrutiny-tests-2.scm:XXX', + At the toplevel, + In procedure call: + + (scheme#list? p) + + The predicate will always return false. + + Procedure `list?' from module `scheme' is a predicate for: + + list + + The given argument has this type: + + (pair fixnum fixnum) + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -137,6 +250,18 @@ Note: Predicate is always false fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -154,6 +279,18 @@ Note: Predicate is always false float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -171,6 +308,18 @@ Note: Predicate is always true null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(null? n))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -188,6 +337,18 @@ Note: Predicate is always true null +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(null? l))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -203,7 +364,19 @@ Note: Predicate is always false The given argument has this type: - pair + (pair fixnum fixnum) + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', @@ -222,6 +395,18 @@ Note: Predicate is always false fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -239,6 +424,18 @@ Note: Predicate is always false float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -256,6 +453,18 @@ Note: Predicate is always true fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(fixnum? i))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -273,6 +482,47 @@ Note: Predicate is always false float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + +Note: Predicate is always false + In file `scrutiny-tests-2.scm:XXX', + At the toplevel, + In procedure call: + + (chicken.base#fixnum? u) + + The predicate will always return false. + + Procedure `fixnum?' from module `chicken.base' is a predicate for: + + fixnum + + The given argument has this type: + + float + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -290,6 +540,47 @@ Note: Predicate is always true float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(flonum? f))) + + Test condition has always true value of type: + + true + +Note: Predicate is always true + In file `scrutiny-tests-2.scm:XXX', + At the toplevel, + In procedure call: + + (chicken.base#flonum? u) + + The predicate will always return true. + + Procedure `flonum?' from module `chicken.base' is a predicate for: + + float + + The given argument has this type: + + float + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(flonum? u))) + + Test condition has always true value of type: + + true + Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -307,6 +598,18 @@ Note: Predicate is always false fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -324,6 +627,18 @@ Note: Predicate is always true fixnum +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(number? i))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -341,6 +656,18 @@ Note: Predicate is always true float +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(number? f))) + + Test condition has always true value of type: + + true + Note: Predicate is always true In file `scrutiny-tests-2.scm:XXX', At the toplevel, @@ -356,7 +683,19 @@ Note: Predicate is always true The given argument has this type: - number + float + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(number? u))) + + Test condition has always true value of type: + + true Note: Predicate is always false In file `scrutiny-tests-2.scm:XXX', @@ -374,3 +713,15 @@ Note: Predicate is always false The given argument has this type: null + +Note: Test is always true + At the toplevel, + In conditional expression: + + (if tmp + tmp + (##sys#error "(scrutiny-tests-2.scm:XXX) assertion failed" '(not ...))) + + Test condition has always true value of type: + + true diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected index b93f9d23..afc7b415 100644 --- a/tests/scrutiny.expected +++ b/tests/scrutiny.expected @@ -661,22 +661,14 @@ Note: Predicate is always false fixnum -Note: Predicate is always false +Note: Test is always false In file `scrutiny-tests.scm:XXX', At the toplevel, - In procedure call: - - (scheme#symbol? x) - - The predicate will always return false. - - Procedure `symbol?' from module `scheme' is a predicate for: - - symbol + In conditional expression: - The given argument has this type: + (if (char-or-string? x) (scheme#symbol? x) (scheme#string? x)) - (or char string) + Test condition is always false. Note: Predicate is always false In file `scrutiny-tests.scm:XXX', -- 2.20.1
signature.asc
Description: PGP signature
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers