~ chicken-core (chicken-5) a2c787e2a944461459133cd6a778440a45746cbd


commit a2c787e2a944461459133cd6a778440a45746cbd
Author:     megane <meganeka@gmail.com>
AuthorDate: Wed Nov 28 13:24:50 2018 +0200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Sat Mar 9 20:38:15 2019 +1300

    Add "In file ..." and "In module ..." to scrutiny messages
    
    This prints `a.module.name#foo-bar-baz' as:
    
      In file `...',
      In module `a.module.name',
      In procedure `foo-bar-baz',
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/scrutinizer.scm b/scrutinizer.scm
index f59ba388..0ebe2122 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -2406,7 +2406,7 @@
 
 (define (node-source-prefix n)
   (let ((line (node-line-number n)))
-    (if (not line) "" (sprintf "(~a) " line))))
+    (if (not line) "" (sprintf "In file `~a'," line))))
 
 (define (location-name loc #!optional (indent "  "))
   (define (lname loc1)
@@ -2414,21 +2414,35 @@
 	(real-name loc1)
 	"(unknown procedure)"))
   (if (null? loc)
-      (sprintf "At toplevel\n~a" indent)
+      (conc "At the toplevel,\n" indent)
       (let rec ((loc loc)
 		(msgs (list "")))
 	(if (null? (cdr loc))
 	    (string-intersperse
-	     (cons (sprintf "In `~a', a toplevel procedure" (lname (car loc))) msgs)
-	     (sprintf "\n~a" indent))
+	     (cons (if (car loc)
+		       ;; If the first location is of format 'bar#foo'
+		       ;; consider it as being being procedure 'foo' in
+		       ;; module 'bar'.
+		       (receive (var mod) (variable-and-module (real-name (car loc)))
+			 (conc (if mod (sprintf "In module `~a',~%~a" mod indent) "")
+			       (sprintf "In procedure `~a'," var)))
+		       "In a toplevel procedure") msgs)
+	     (conc "\n" indent))
 	    (rec (cdr loc)
-		 (cons (sprintf "In `~a', a local procedure" (lname (car loc))) msgs))))))
+		 (cons (sprintf "In procedure `~a'," (lname (car loc))) msgs))))))
+
+(define (variable-and-module name) ; -> (values var module-or-false)
+  (let* ((str-name (if (symbol? name) (symbol->string name) name))
+	 (r (string-split str-name "#" #t)))
+    (if (pair? (cdr r))
+	(values (string->symbol (second r)) (string->symbol (first r)))
+	(values (string->symbol str-name) #f))))
 
 (define (variable-from-module sym)
-  (let ((r (string-split (symbol->string sym) "#" #t)))
-    (if (= (length r) 2)
-	(sprintf "`~a' from module `~a'" (second r) (first r))
-	(sprintf "`~a'" sym))))
+  (receive (var mod) (variable-and-module sym)
+    (if mod
+	(sprintf "`~a' from module `~a'" var mod)
+	(sprintf "`~a'" var))))
 
 (define (describe-expression node)
   (define (p-expr n)
@@ -2466,9 +2480,10 @@
     (report-f
      (conc
       short
-      (let ((l (file-location))) (if l (conc " " l) ""))
       (string-add-indent
-       (conc "\n" (location-name loc "") (sprintf "~?" msg args))
+       (conc (let ((l (file-location))) (if l (conc "\n" l) "")) "\n"
+	     (location-name loc "")
+	     (sprintf "~?" msg args))
        "  ")))
     (flush-output)))
 
@@ -2849,6 +2864,7 @@
   (quit-compiling
    (string-append
     "No typecase match"
+    "~%"
     "~a"
     "~a"
     "In `compiler-typecase' expression:"
@@ -2866,7 +2882,7 @@
     "~a")
    (if (string=? "" (node-source-prefix node))
        "\n"
-       (conc " " (node-source-prefix node) "\n  "))
+       (conc "  " (node-source-prefix node) "\n  "))
    (location-name loc)
    (pp-fragment node)
    (pp-type atype)
diff --git a/tests/scrutinizer-message-format.expected b/tests/scrutinizer-message-format.expected
index eeaf7d2a..f6f3b256 100644
--- a/tests/scrutinizer-message-format.expected
+++ b/tests/scrutinizer-message-format.expected
@@ -5,8 +5,9 @@ Warning: literal in operator position: (1 2)
 
 Warning: literal in operator position: (1 2)
 
-Warning: Wrong number of arguments (test-scrutinizer-message-format.scm:XXX) 
-  In `r-proc-call-argument-count-mismatch', a toplevel procedure
+Warning: Wrong number of arguments
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-proc-call-argument-count-mismatch',
   In procedure call:
 
     (scheme#cons '())
@@ -17,8 +18,9 @@ Warning: Wrong number of arguments (test-scrutinizer-message-format.scm:XXX)
 
     ('aXXX 'bXXX --> (pair 'aXXX 'bXXX))
 
-Warning: Invalid argument (test-scrutinizer-message-format.scm:XXX) 
-  In `r-proc-call-argument-type-mismatch', a toplevel procedure
+Warning: Invalid argument
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-proc-call-argument-type-mismatch',
   In procedure call:
 
     (scheme#length 'symbol)
@@ -39,8 +41,9 @@ Warning: Invalid argument (test-scrutinizer-message-format.scm:XXX)
 
     (list -> fixnum)
 
-Warning: Too many argument values (test-scrutinizer-message-format.scm:XXX) 
-  In `r-proc-call-argument-value-count', a toplevel procedure
+Warning: Too many argument values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-proc-call-argument-value-count',
   In procedure call:
 
     (scheme#list (chicken.time#cpu-time))
@@ -55,8 +58,9 @@ Warning: Too many argument values (test-scrutinizer-message-format.scm:XXX)
 
     (chicken.time#cpu-time)
 
-Warning: Not enough argument values (test-scrutinizer-message-format.scm:XXX) 
-  In `r-proc-call-argument-value-count', a toplevel procedure
+Warning: Not enough argument values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-proc-call-argument-value-count',
   In procedure call:
 
     (scheme#vector (scheme#values))
@@ -71,8 +75,9 @@ Warning: Not enough argument values (test-scrutinizer-message-format.scm:XXX)
 
     (scheme#values)
 
-Warning: Let binding to `gXXX' has zero values (test-scrutinizer-message-format.scm:XXX) 
-  In `r-proc-call-argument-value-count', a toplevel procedure
+Warning: Let binding to `gXXX' has zero values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-proc-call-argument-value-count',
   In let expression:
 
     (let ((gXXX (scheme#values))) (gXXX))
@@ -87,8 +92,9 @@ Warning: Let binding to `gXXX' has zero values (test-scrutinizer-message-format.
 
     (scheme#values)
 
-Warning: Branch values mismatch (test-scrutinizer-message-format.scm:XXX) 
-  In `r-cond-branch-value-count-mismatch', a toplevel procedure
+Warning: Branch values mismatch
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-cond-branch-value-count-mismatch',
   In conditional expression:
 
     (if (the * 1) 1 (scheme#values 1 2))
@@ -104,7 +110,7 @@ Warning: Branch values mismatch (test-scrutinizer-message-format.scm:XXX)
     (scheme#values 1 2)
 
 Warning: Invalid procedure
-  In `r-invalid-called-procedure-type', a toplevel procedure
+  In procedure `r-invalid-called-procedure-type',
   In procedure call:
 
     (1 2)
@@ -123,8 +129,9 @@ Warning: Invalid procedure
 
     fixnum
 
-Note: Predicate is always true (test-scrutinizer-message-format.scm:XXX) 
-  In `r-pred-call-always-true', a toplevel procedure
+Note: Predicate is always true
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-pred-call-always-true',
   In procedure call:
 
     (scheme#list? '())
@@ -139,8 +146,9 @@ Note: Predicate is always true (test-scrutinizer-message-format.scm:XXX)
 
     null
 
-Note: Predicate is always false (test-scrutinizer-message-format.scm:XXX) 
-  In `r-pred-call-always-false', a toplevel procedure
+Note: Predicate is always false
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-pred-call-always-false',
   In procedure call:
 
     (scheme#symbol? 1)
@@ -156,7 +164,7 @@ Note: Predicate is always false (test-scrutinizer-message-format.scm:XXX)
     fixnum
 
 Note: Test is always true
-  In `r-cond-test-always-true', a toplevel procedure
+  In procedure `r-cond-test-always-true',
   In conditional expression:
 
     (if 'symbol 1 (##core#undefined))
@@ -166,7 +174,7 @@ Note: Test is always true
     symbol
 
 Note: Test is always false
-  In `r-cond-test-always-false', a toplevel procedure
+  In procedure `r-cond-test-always-false',
   In conditional expression:
 
     (if #f 1 (##core#undefined))
@@ -174,7 +182,7 @@ Note: Test is always false
   Test condition is always false.
 
 Warning: Type mismatch
-  In `r-type-mismatch-in-the', a toplevel procedure
+  In procedure `r-type-mismatch-in-the',
   In expression:
 
     1
@@ -189,8 +197,9 @@ Warning: Type mismatch
 
     fixnum
 
-Warning: Not enough values (test-scrutinizer-message-format.scm:XXX) 
-  In `r-zero-values-for-the', a toplevel procedure
+Warning: Not enough values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-zero-values-for-the',
   In expression:
 
     (scheme#values)
@@ -199,8 +208,9 @@ Warning: Not enough values (test-scrutinizer-message-format.scm:XXX)
 
     symbol
 
-Warning: Too many values (test-scrutinizer-message-format.scm:XXX) 
-  In `r-too-many-values-for-the', a toplevel procedure
+Warning: Too many values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-too-many-values-for-the',
   In expression:
 
     (scheme#values 1 2)
@@ -211,8 +221,9 @@ Warning: Too many values (test-scrutinizer-message-format.scm:XXX)
 
     symbol
 
-Warning: Type mismatch (test-scrutinizer-message-format.scm:XXX) 
-  In `r-too-many-values-for-the', a toplevel procedure
+Warning: Type mismatch
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `r-too-many-values-for-the',
   In expression:
 
     (scheme#values 1 2)
@@ -228,7 +239,7 @@ Warning: Type mismatch (test-scrutinizer-message-format.scm:XXX)
     fixnum
 
 Warning: Invalid assignment
-  In `r-toplevel-var-assignment-type-mismatch', a toplevel procedure
+  In procedure `r-toplevel-var-assignment-type-mismatch',
   In assignment:
 
     (set! foo 1)
@@ -244,7 +255,7 @@ Warning: Invalid assignment
     boolean
 
 Warning: Deprecated identifier `deprecated-foo'
-  In `r-deprecated-identifier', a toplevel procedure
+  In procedure `r-deprecated-identifier',
   In expression:
 
     deprecated-foo
@@ -252,7 +263,7 @@ Warning: Deprecated identifier `deprecated-foo'
   Use of deprecated identifier `deprecated-foo'.
 
 Warning: Deprecated identifier `deprecated-foo2'
-  In `r-deprecated-identifier', a toplevel procedure
+  In procedure `r-deprecated-identifier',
   In expression:
 
     deprecated-foo2
@@ -262,7 +273,7 @@ Warning: Deprecated identifier `deprecated-foo2'
   The suggested alternative is `foo'.
 
 Warning: Invalid assignment
-  At toplevel
+  At the toplevel,
   In assignment:
 
     (set! foo 1)
@@ -277,32 +288,36 @@ Warning: Invalid assignment
 
     boolean
 
-Warning: Negative list index (test-scrutinizer-message-format.scm:XXX) 
-  In `list-ref-negative-index', a toplevel procedure
+Warning: Negative list index
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `list-ref-negative-index',
   In procedure call:
 
     (scheme#list-ref '() -1)
 
   Procedure `list-ref' from module `scheme' is called with a negative index -1.
 
-Warning: List index out of range (test-scrutinizer-message-format.scm:XXX) 
-  In `list-ref-out-of-range', a toplevel procedure
+Warning: List index out of range
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `list-ref-out-of-range',
   In procedure call:
 
     (scheme#list-ref '() 1)
 
   Procedure `list-ref' from module `scheme' is called with index `1' for a list of length `0'.
 
-Warning: Negative vector index (test-scrutinizer-message-format.scm:XXX) 
-  In `vector-ref-out-of-range', a toplevel procedure
+Warning: Negative vector index
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `vector-ref-out-of-range',
   In procedure call:
 
     (scheme#vector-ref (scheme#vector) -1)
 
   Procedure `vector-ref' from module `scheme' is called with a negative index -1.
 
-Warning: Let binding to `a' has zero values (test-scrutinizer-message-format.scm:XXX) 
-  In `zero-values-for-let', a toplevel procedure
+Warning: Let binding to `a' has zero values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `zero-values-for-let',
   In let expression:
 
     (let ((a (scheme#values))) a)
@@ -317,8 +332,9 @@ Warning: Let binding to `a' has zero values (test-scrutinizer-message-format.scm
 
     (scheme#values)
 
-Warning: Let binding to `a' has 2 values (test-scrutinizer-message-format.scm:XXX) 
-  In `multiple-values-for-let', a toplevel procedure
+Warning: Let binding to `a' has 2 values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `multiple-values-for-let',
   In let expression:
 
     (let ((a (scheme#values 1 2))) a)
@@ -333,8 +349,9 @@ Warning: Let binding to `a' has 2 values (test-scrutinizer-message-format.scm:XX
 
     (scheme#values 1 2)
 
-Warning: Zero values for conditional (test-scrutinizer-message-format.scm:XXX) 
-  In `zero-values-for-conditional', a toplevel procedure
+Warning: Zero values for conditional
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `zero-values-for-conditional',
   In conditional:
 
     (if (scheme#values) 1 (##core#undefined))
@@ -349,8 +366,9 @@ Warning: Zero values for conditional (test-scrutinizer-message-format.scm:XXX)
 
     (scheme#values)
 
-Warning: Too many values for conditional (test-scrutinizer-message-format.scm:XXX) 
-  In `multiple-values-for-conditional', a toplevel procedure
+Warning: Too many values for conditional
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `multiple-values-for-conditional',
   In conditional:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -365,8 +383,9 @@ Warning: Too many values for conditional (test-scrutinizer-message-format.scm:XX
 
     (scheme#values 1 2)
 
-Note: Test is always true (test-scrutinizer-message-format.scm:XXX) 
-  In `multiple-values-for-conditional', a toplevel procedure
+Note: Test is always true
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `multiple-values-for-conditional',
   In conditional expression:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -375,8 +394,9 @@ Note: Test is always true (test-scrutinizer-message-format.scm:XXX)
 
     fixnum
 
-Warning: Let binding to `gXXX' has 2 values (test-scrutinizer-message-format.scm:XXX) 
-  In `multiple-values-for-conditional', a toplevel procedure
+Warning: Let binding to `gXXX' has 2 values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In procedure `multiple-values-for-conditional',
   In let expression:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -391,10 +411,12 @@ Warning: Let binding to `gXXX' has 2 values (test-scrutinizer-message-format.scm
 
     (scheme#values 1 2)
 
-Warning: Wrong number of arguments (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-proc-call-argument-count-mismatch', a local procedure
+Warning: Wrong number of arguments
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-proc-call-argument-count-mismatch',
   In procedure call:
 
     (scheme#cons '())
@@ -405,10 +427,12 @@ Warning: Wrong number of arguments (test-scrutinizer-message-format.scm:XXX)
 
     ('aXXX 'bXXX --> (pair 'aXXX 'bXXX))
 
-Warning: Invalid argument (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-proc-call-argument-type-mismatch', a local procedure
+Warning: Invalid argument
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-proc-call-argument-type-mismatch',
   In procedure call:
 
     (scheme#length 'symbol)
@@ -429,10 +453,12 @@ Warning: Invalid argument (test-scrutinizer-message-format.scm:XXX)
 
     (list -> fixnum)
 
-Warning: Too many argument values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-proc-call-argument-value-count', a local procedure
+Warning: Too many argument values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-proc-call-argument-value-count',
   In procedure call:
 
     (scheme#list (chicken.time#cpu-time))
@@ -447,10 +473,12 @@ Warning: Too many argument values (test-scrutinizer-message-format.scm:XXX)
 
     (chicken.time#cpu-time)
 
-Warning: Not enough argument values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-proc-call-argument-value-count', a local procedure
+Warning: Not enough argument values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-proc-call-argument-value-count',
   In procedure call:
 
     (scheme#vector (scheme#values))
@@ -465,10 +493,12 @@ Warning: Not enough argument values (test-scrutinizer-message-format.scm:XXX)
 
     (scheme#values)
 
-Warning: Let binding to `gXXX' has zero values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-proc-call-argument-value-count', a local procedure
+Warning: Let binding to `gXXX' has zero values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-proc-call-argument-value-count',
   In let expression:
 
     (let ((gXXX (scheme#values))) (gXXX))
@@ -483,10 +513,12 @@ Warning: Let binding to `gXXX' has zero values (test-scrutinizer-message-format.
 
     (scheme#values)
 
-Warning: Branch values mismatch (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-cond-branch-value-count-mismatch', a local procedure
+Warning: Branch values mismatch
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-cond-branch-value-count-mismatch',
   In conditional expression:
 
     (if (the * 1) 1 (chicken.time#cpu-time))
@@ -502,9 +534,10 @@ Warning: Branch values mismatch (test-scrutinizer-message-format.scm:XXX)
     (chicken.time#cpu-time)
 
 Warning: Invalid procedure
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-invalid-called-procedure-type', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-invalid-called-procedure-type',
   In procedure call:
 
     (1 2)
@@ -523,10 +556,12 @@ Warning: Invalid procedure
 
     fixnum
 
-Note: Predicate is always true (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-pred-call-always-true', a local procedure
+Note: Predicate is always true
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-pred-call-always-true',
   In procedure call:
 
     (scheme#list? '())
@@ -541,10 +576,12 @@ Note: Predicate is always true (test-scrutinizer-message-format.scm:XXX)
 
     null
 
-Note: Predicate is always false (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-pred-call-always-false', a local procedure
+Note: Predicate is always false
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-pred-call-always-false',
   In procedure call:
 
     (scheme#symbol? 1)
@@ -559,10 +596,12 @@ Note: Predicate is always false (test-scrutinizer-message-format.scm:XXX)
 
     fixnum
 
-Note: Test is always true (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-cond-test-always-true', a local procedure
+Note: Test is always true
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-cond-test-always-true',
   In conditional expression:
 
     (if (scheme#length '()) 1 (##core#undefined))
@@ -572,9 +611,10 @@ Note: Test is always true (test-scrutinizer-message-format.scm:XXX)
     fixnum
 
 Note: Test is always false
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-cond-test-always-false', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-cond-test-always-false',
   In conditional expression:
 
     (if #f 1 (##core#undefined))
@@ -582,9 +622,10 @@ Note: Test is always false
   Test condition is always false.
 
 Warning: Type mismatch
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-type-mismatch-in-the', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-type-mismatch-in-the',
   In expression:
 
     1
@@ -599,10 +640,12 @@ Warning: Type mismatch
 
     fixnum
 
-Warning: Not enough values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-zero-values-for-the', a local procedure
+Warning: Not enough values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-zero-values-for-the',
   In expression:
 
     (scheme#values)
@@ -611,10 +654,12 @@ Warning: Not enough values (test-scrutinizer-message-format.scm:XXX)
 
     symbol
 
-Warning: Too many values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-too-many-values-for-the', a local procedure
+Warning: Too many values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-too-many-values-for-the',
   In expression:
 
     (scheme#values 1 2)
@@ -625,10 +670,12 @@ Warning: Too many values (test-scrutinizer-message-format.scm:XXX)
 
     symbol
 
-Warning: Type mismatch (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-too-many-values-for-the', a local procedure
+Warning: Type mismatch
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-too-many-values-for-the',
   In expression:
 
     (scheme#values 1 2)
@@ -644,9 +691,10 @@ Warning: Type mismatch (test-scrutinizer-message-format.scm:XXX)
     fixnum
 
 Warning: Invalid assignment
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-toplevel-var-assignment-type-mismatch', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-toplevel-var-assignment-type-mismatch',
   In assignment:
 
     (set! m#foo2 1)
@@ -662,9 +710,10 @@ Warning: Invalid assignment
     boolean
 
 Warning: Deprecated identifier `deprecated-foo'
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-deprecated-identifier', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-deprecated-identifier',
   In expression:
 
     m#deprecated-foo
@@ -672,9 +721,10 @@ Warning: Deprecated identifier `deprecated-foo'
   Use of deprecated identifier `deprecated-foo' from module `m'.
 
 Warning: Deprecated identifier `deprecated-foo2'
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `r-deprecated-identifier', a local procedure
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `r-deprecated-identifier',
   In expression:
 
     m#deprecated-foo2
@@ -683,40 +733,48 @@ Warning: Deprecated identifier `deprecated-foo2'
 
   The suggested alternative is `foo'.
 
-Warning: Negative list index (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `list-ref-negative-index', a local procedure
+Warning: Negative list index
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `list-ref-negative-index',
   In procedure call:
 
     (scheme#list-ref '() -1)
 
   Procedure `list-ref' from module `scheme' is called with a negative index -1.
 
-Warning: List index out of range (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `list-ref-out-of-range', a local procedure
+Warning: List index out of range
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `list-ref-out-of-range',
   In procedure call:
 
     (scheme#list-ref '() 1)
 
   Procedure `list-ref' from module `scheme' is called with index `1' for a list of length `0'.
 
-Warning: Negative vector index (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `vector-ref-out-of-range', a local procedure
+Warning: Negative vector index
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `vector-ref-out-of-range',
   In procedure call:
 
     (scheme#vector-ref (scheme#vector) -1)
 
   Procedure `vector-ref' from module `scheme' is called with a negative index -1.
 
-Warning: Let binding to `a' has zero values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `zero-values-for-let', a local procedure
+Warning: Let binding to `a' has zero values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `zero-values-for-let',
   In let expression:
 
     (let ((a (scheme#values))) a)
@@ -731,10 +789,12 @@ Warning: Let binding to `a' has zero values (test-scrutinizer-message-format.scm
 
     (scheme#values)
 
-Warning: Let binding to `a' has 2 values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `multiple-values-for-let', a local procedure
+Warning: Let binding to `a' has 2 values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `multiple-values-for-let',
   In let expression:
 
     (let ((a (scheme#values 1 2))) a)
@@ -749,10 +809,12 @@ Warning: Let binding to `a' has 2 values (test-scrutinizer-message-format.scm:XX
 
     (scheme#values 1 2)
 
-Warning: Zero values for conditional (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `zero-values-for-conditional', a local procedure
+Warning: Zero values for conditional
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `zero-values-for-conditional',
   In conditional:
 
     (if (scheme#values) 1 (##core#undefined))
@@ -767,10 +829,12 @@ Warning: Zero values for conditional (test-scrutinizer-message-format.scm:XXX)
 
     (scheme#values)
 
-Warning: Too many values for conditional (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `multiple-values-for-conditional', a local procedure
+Warning: Too many values for conditional
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `multiple-values-for-conditional',
   In conditional:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -785,10 +849,12 @@ Warning: Too many values for conditional (test-scrutinizer-message-format.scm:XX
 
     (scheme#values 1 2)
 
-Note: Test is always true (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `multiple-values-for-conditional', a local procedure
+Note: Test is always true
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `multiple-values-for-conditional',
   In conditional expression:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -797,10 +863,12 @@ Note: Test is always true (test-scrutinizer-message-format.scm:XXX)
 
     fixnum
 
-Warning: Let binding to `gXXX' has 2 values (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `multiple-values-for-conditional', a local procedure
+Warning: Let binding to `gXXX' has 2 values
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `multiple-values-for-conditional',
   In let expression:
 
     (if (scheme#values 1 2) 1 (##core#undefined))
@@ -815,10 +883,12 @@ Warning: Let binding to `gXXX' has 2 values (test-scrutinizer-message-format.scm
 
     (scheme#values 1 2)
 
-Error: No typecase match (test-scrutinizer-message-format.scm:XXX) 
-  In `m#toplevel-foo', a toplevel procedure
-  In `local-bar', a local procedure
-  In `fail-compiler-typecase', a local procedure
+Error: No typecase match
+  In file `test-scrutinizer-message-format.scm:XXX',
+  In module `m',
+  In procedure `toplevel-foo',
+  In procedure `local-bar',
+  In procedure `fail-compiler-typecase',
   In `compiler-typecase' expression:
 
     (compiler-typecase gXXX (symbol 1) (list 2) (else (##core#undefined)))
diff --git a/tests/scrutiny-2.expected b/tests/scrutiny-2.expected
index 78500cdc..44315153 100644
--- a/tests/scrutiny-2.expected
+++ b/tests/scrutiny-2.expected
@@ -1,8 +1,9 @@
 ;; numbers replaced with XXX by redact-gensyms.scm
 ;; prefixes: (tmp g scm:)
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#pair? p)
@@ -17,8 +18,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     pair
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#pair? l)
@@ -33,8 +35,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#pair? n)
@@ -49,8 +52,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#pair? i)
@@ -65,8 +69,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#pair? f)
@@ -81,8 +86,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#list? l)
@@ -97,8 +103,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#list? n)
@@ -113,8 +120,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#list? i)
@@ -129,8 +137,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#list? f)
@@ -145,8 +154,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#null? n)
@@ -161,8 +171,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#null? l)
@@ -177,8 +188,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     null
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#null? p)
@@ -193,8 +205,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     pair
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#null? i)
@@ -209,8 +222,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#null? f)
@@ -225,8 +239,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#fixnum? i)
@@ -241,8 +256,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#fixnum? f)
@@ -257,8 +273,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#flonum? f)
@@ -273,8 +290,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#flonum? i)
@@ -289,8 +307,9 @@ Note: Predicate is always false (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#number? i)
@@ -305,8 +324,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     fixnum
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#number? f)
@@ -321,8 +341,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     float
 
-Note: Predicate is always true (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#number? u)
@@ -337,8 +358,9 @@ Note: Predicate is always true (scrutiny-tests-2.scm:XXX)
 
     number
 
-Note: Predicate is always false (scrutiny-tests-2.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests-2.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#number? n)
diff --git a/tests/scrutiny.expected b/tests/scrutiny.expected
index bb42c9f6..cc01b6fb 100644
--- a/tests/scrutiny.expected
+++ b/tests/scrutiny.expected
@@ -4,9 +4,9 @@
 Warning: (scrutiny-tests.scm:XXX) - assignment to imported value binding `car'
 
 Note: Test is always true
-  In `a', a toplevel procedure
-  In `b', a local procedure
-  In `c', a local procedure
+  In procedure `a',
+  In procedure `b',
+  In procedure `c',
   In conditional expression:
 
     (if x 1 2)
@@ -16,7 +16,7 @@ Note: Test is always true
     number
 
 Note: Test is always true
-  In `b', a toplevel procedure
+  In procedure `b',
   In conditional expression:
 
     (if x 1 2)
@@ -25,8 +25,9 @@ Note: Test is always true
 
     true
 
-Warning: Branch values mismatch (scrutiny-tests.scm:XXX) 
-  In `foo', a toplevel procedure
+Warning: Branch values mismatch
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo',
   In conditional expression:
 
     (if x (scheme#values 1 2) (scheme#values 1 2 (scheme#+ (scheme#+ ...))))
@@ -41,8 +42,9 @@ Warning: Branch values mismatch (scrutiny-tests.scm:XXX)
 
     (scheme#values 1 2 (scheme#+ (scheme#+ (scheme#+ ...))))
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (bar 3 'a)
@@ -63,8 +65,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Wrong number of arguments (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Wrong number of arguments
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string?)
@@ -75,8 +78,9 @@ Warning: Wrong number of arguments (scrutiny-tests.scm:XXX)
 
     (* -> boolean)
 
-Warning: Too many argument values (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Too many argument values
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#print (scheme#values 1 2))
@@ -91,8 +95,9 @@ Warning: Too many argument values (scrutiny-tests.scm:XXX)
 
     (scheme#values 1 2)
 
-Warning: Not enough argument values (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Not enough argument values
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#print (scheme#values))
@@ -107,8 +112,9 @@ Warning: Not enough argument values (scrutiny-tests.scm:XXX)
 
     (scheme#values)
 
-Warning: Invalid procedure (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid procedure
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (x)
@@ -119,8 +125,9 @@ Warning: Invalid procedure (scrutiny-tests.scm:XXX)
 
     fixnum
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#+ 'a 'b)
@@ -141,8 +148,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#+ 'a 'b)
@@ -164,7 +172,7 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
     (#!rest number -> number)
 
 Warning: Invalid assignment
-  At toplevel
+  At the toplevel,
   In assignment:
 
     (set! scheme#car 33)
@@ -179,8 +187,9 @@ Warning: Invalid assignment
 
     ((pair 'a335 *) -> 'a335)
 
-Warning: Let binding to `gXXX' has 2 values (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Let binding to `gXXX' has 2 values
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In let expression:
 
     (let ((gXXX (scheme#values 1 2))) (gXXX))
@@ -196,7 +205,7 @@ Warning: Let binding to `gXXX' has 2 values (scrutiny-tests.scm:XXX)
     (scheme#values 1 2)
 
 Warning: Invalid procedure
-  At toplevel
+  At the toplevel,
   In procedure call:
 
     (gXXX)
@@ -208,7 +217,7 @@ Warning: Invalid procedure
     fixnum
 
 Note: Test is always true
-  In `foo', a toplevel procedure
+  In procedure `foo',
   In conditional expression:
 
     (if bar 3 (##core#undefined))
@@ -217,8 +226,9 @@ Note: Test is always true
 
     (-> *)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo2', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo2',
   In procedure call:
 
     (scheme#string-append x "abc")
@@ -239,8 +249,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest string -> string)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (foo3 99)
@@ -261,8 +272,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (string -> string)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo4', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo4',
   In procedure call:
 
     (scheme#+ x 1)
@@ -283,8 +295,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo5', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo5',
   In procedure call:
 
     (scheme#+ x 3)
@@ -305,8 +318,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo6', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo6',
   In procedure call:
 
     (scheme#+ x 3)
@@ -327,8 +341,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#+ x 1)
@@ -349,8 +364,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In procedure call:
 
     (foo9 x)
@@ -371,8 +387,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (string -> symbol)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In procedure call:
 
     (scheme#+ x 1)
@@ -393,8 +410,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Type mismatch (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Type mismatch
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In expression:
 
     (scheme#substring x 0 10)
@@ -409,8 +427,9 @@ Warning: Type mismatch (scrutiny-tests.scm:XXX)
 
     string
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In procedure call:
 
     (scheme#string-append (the pair (scheme#substring x 0 10)))
@@ -431,8 +450,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest string -> string)
 
-Warning: Too many values (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Too many values
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In expression:
 
     (scheme#values 1 2)
@@ -443,8 +463,9 @@ Warning: Too many values (scrutiny-tests.scm:XXX)
 
     *
 
-Warning: Not enough values (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Not enough values
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In expression:
 
     (scheme#values)
@@ -453,8 +474,9 @@ Warning: Not enough values (scrutiny-tests.scm:XXX)
 
     *
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo10', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `foo10',
   In procedure call:
 
     (scheme#* x y)
@@ -475,8 +497,10 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (#!rest number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `foo#blabla', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In module `foo',
+  In procedure `blabla',
   In procedure call:
 
     (scheme#+ 1 'x)
@@ -498,7 +522,7 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
     (#!rest number -> number)
 
 Warning: Deprecated identifier `deprecated-procedure'
-  At toplevel
+  At the toplevel,
   In expression:
 
     deprecated-procedure
@@ -506,7 +530,7 @@ Warning: Deprecated identifier `deprecated-procedure'
   Use of deprecated identifier `deprecated-procedure'.
 
 Warning: Deprecated identifier `another-deprecated-procedure'
-  At toplevel
+  At the toplevel,
   In expression:
 
     another-deprecated-procedure
@@ -515,8 +539,9 @@ Warning: Deprecated identifier `another-deprecated-procedure'
 
   The suggested alternative is `replacement-procedure'.
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (apply1 scheme#+ (scheme#list 'a 2 3))
@@ -541,8 +566,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((#!rest 'a143 -> 'b144) (list-of 'a143) -> 'b144)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (apply1 scheme#+ (scheme#cons 'a (scheme#cons 2 (scheme#cons 3 ...))))
@@ -567,8 +593,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((#!rest 'a143 -> 'b144) (list-of 'a143) -> 'b144)
 
-Note: Predicate is always true (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (chicken.base#fixnum? x)
@@ -583,8 +610,9 @@ Note: Predicate is always true (scrutiny-tests.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#symbol? x)
@@ -599,8 +627,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     (or char string)
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? x)
@@ -615,8 +644,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     (not (or char string))
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (char-or-string? x)
@@ -631,8 +661,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#symbol? x)
@@ -647,8 +678,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     (or char string)
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? x)
@@ -663,8 +695,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     fixnum
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#symbol? x)
@@ -679,8 +712,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     char
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? x)
@@ -695,8 +729,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     symbol
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#symbol? x)
@@ -711,8 +746,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     (or char string)
 
-Note: Predicate is always false (scrutiny-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? x)
@@ -727,8 +763,9 @@ Note: Predicate is always false (scrutiny-tests.scm:XXX)
 
     symbol
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (f (scheme#list))
@@ -753,8 +790,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (pair -> *)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (f (scheme#list 1))
@@ -779,8 +817,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (null -> *)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  At toplevel
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (f (scheme#cons 1 2))
@@ -805,32 +844,36 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (list -> *)
 
-Warning: Negative vector index (scrutiny-tests.scm:XXX) 
-  In `vector-ref-warn1', a toplevel procedure
+Warning: Negative vector index
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-ref-warn1',
   In procedure call:
 
     (scheme#vector-ref v1 -1)
 
   Procedure `vector-ref' from module `scheme' is called with a negative index -1.
 
-Warning: Vector index out of range (scrutiny-tests.scm:XXX) 
-  In `vector-ref-warn2', a toplevel procedure
+Warning: Vector index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-ref-warn2',
   In procedure call:
 
     (scheme#vector-ref v1 3)
 
   Procedure `vector-ref' from module `scheme' is called with index `3' for a vector of length `3'.
 
-Warning: Vector index out of range (scrutiny-tests.scm:XXX) 
-  In `vector-ref-warn3', a toplevel procedure
+Warning: Vector index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-ref-warn3',
   In procedure call:
 
     (scheme#vector-ref v1 4)
 
   Procedure `vector-ref' from module `scheme' is called with index `4' for a vector of length `3'.
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `vector-ref-standard-warn1', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-ref-standard-warn1',
   In procedure call:
 
     (scheme#vector-ref v1 'bad)
@@ -851,32 +894,36 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((vector-of 'a384) fixnum -> 'a384)
 
-Warning: Negative vector index (scrutiny-tests.scm:XXX) 
-  In `vector-set!-warn1', a toplevel procedure
+Warning: Negative vector index
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-set!-warn1',
   In procedure call:
 
     (scheme#vector-set! v1 -1 'whatever)
 
   Procedure `vector-set!' from module `scheme' is called with a negative index -1.
 
-Warning: Vector index out of range (scrutiny-tests.scm:XXX) 
-  In `vector-set!-warn2', a toplevel procedure
+Warning: Vector index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-set!-warn2',
   In procedure call:
 
     (scheme#vector-set! v1 3 'whatever)
 
   Procedure `vector-set!' from module `scheme' is called with index `3' for a vector of length `3'.
 
-Warning: Vector index out of range (scrutiny-tests.scm:XXX) 
-  In `vector-set!-warn3', a toplevel procedure
+Warning: Vector index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-set!-warn3',
   In procedure call:
 
     (scheme#vector-set! v1 4 'whatever)
 
   Procedure `vector-set!' from module `scheme' is called with index `4' for a vector of length `3'.
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `vector-set!-standard-warn1', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `vector-set!-standard-warn1',
   In procedure call:
 
     (scheme#vector-set! v1 'bad 'whatever)
@@ -897,48 +944,54 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (vector fixnum * -> undefined)
 
-Warning: Negative list index (scrutiny-tests.scm:XXX) 
-  In `list-ref-warn1', a toplevel procedure
+Warning: Negative list index
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-warn1',
   In procedure call:
 
     (scheme#list-ref l1 -1)
 
   Procedure `list-ref' from module `scheme' is called with a negative index -1.
 
-Warning: Negative list index (scrutiny-tests.scm:XXX) 
-  In `list-ref-warn2', a toplevel procedure
+Warning: Negative list index
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-warn2',
   In procedure call:
 
     (scheme#list-ref l2 -1)
 
   Procedure `list-ref' from module `scheme' is called with a negative index -1.
 
-Warning: Negative list index (scrutiny-tests.scm:XXX) 
-  In `list-ref-warn3', a toplevel procedure
+Warning: Negative list index
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-warn3',
   In procedure call:
 
     (scheme#list-ref l3 -1)
 
   Procedure `list-ref' from module `scheme' is called with a negative index -1.
 
-Warning: List index out of range (scrutiny-tests.scm:XXX) 
-  In `list-ref-warn4', a toplevel procedure
+Warning: List index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-warn4',
   In procedure call:
 
     (scheme#list-ref l1 3)
 
   Procedure `list-ref' from module `scheme' is called with index `3' for a list of length `3'.
 
-Warning: List index out of range (scrutiny-tests.scm:XXX) 
-  In `list-ref-warn5', a toplevel procedure
+Warning: List index out of range
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-warn5',
   In procedure call:
 
     (scheme#list-ref l1 4)
 
   Procedure `list-ref' from module `scheme' is called with index `4' for a list of length `3'.
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-standard-warn1', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-standard-warn1',
   In procedure call:
 
     (scheme#list-ref l1 'bad)
@@ -959,8 +1012,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((list-of 'a366) fixnum -> 'a366)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-standard-warn2', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-standard-warn2',
   In procedure call:
 
     (scheme#list-ref l1 'bad)
@@ -981,8 +1035,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((list-of 'a366) fixnum -> 'a366)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-standard-warn3', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-standard-warn3',
   In procedure call:
 
     (scheme#list-ref l2 'bad)
@@ -1003,8 +1058,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((list-of 'a366) fixnum -> 'a366)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-standard-warn4', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-standard-warn4',
   In procedure call:
 
     (scheme#list-ref l2 'bad)
@@ -1025,8 +1081,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     ((list-of 'a366) fixnum -> 'a366)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-type-warn1', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-type-warn1',
   In procedure call:
 
     (chicken.base#add1 (scheme#list-ref l1 1))
@@ -1051,8 +1108,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-type-warn2', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-type-warn2',
   In procedure call:
 
     (chicken.base#add1 (scheme#list-ref l2 1))
@@ -1077,8 +1135,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `list-ref-type-warn3', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `list-ref-type-warn3',
   In procedure call:
 
     (chicken.base#add1 (scheme#list-ref l3 1))
@@ -1103,8 +1162,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `append-result-type-warn1', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `append-result-type-warn1',
   In procedure call:
 
     (chicken.base#add1 (scheme#list-ref l1 1))
@@ -1129,8 +1189,9 @@ Warning: Invalid argument (scrutiny-tests.scm:XXX)
 
     (number -> number)
 
-Warning: Invalid argument (scrutiny-tests.scm:XXX) 
-  In `append-result-type-warn2', a toplevel procedure
+Warning: Invalid argument
+  In file `scrutiny-tests.scm:XXX',
+  In procedure `append-result-type-warn2',
   In procedure call:
 
     (chicken.base#add1 (scheme#list-ref l3 3))
diff --git a/tests/specialization.expected b/tests/specialization.expected
index 57ce4feb..64307637 100644
--- a/tests/specialization.expected
+++ b/tests/specialization.expected
@@ -1,8 +1,9 @@
 ;; numbers replaced with XXX by redact-gensyms.scm
 ;; prefixes: (tmp g scm:)
 
-Note: Predicate is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? a)
@@ -17,8 +18,9 @@ Note: Predicate is always true (specialization-tests.scm:XXX)
 
     string
 
-Note: Test is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Test is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In conditional expression:
 
     (if (scheme#string? a) 'ok 'no)
@@ -27,8 +29,9 @@ Note: Test is always true (specialization-tests.scm:XXX)
 
     true
 
-Note: Predicate is always false (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always false
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#string? a)
@@ -43,16 +46,18 @@ Note: Predicate is always false (specialization-tests.scm:XXX)
 
     symbol
 
-Note: Test is always false (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Test is always false
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In conditional expression:
 
     (if (scheme#string? a) 'ok 'no)
 
   Test condition is always false.
 
-Note: Predicate is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#input-port? p)
@@ -67,8 +72,9 @@ Note: Predicate is always true (specialization-tests.scm:XXX)
 
     input/output-port
 
-Note: Test is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Test is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In conditional expression:
 
     (if (scheme#input-port? p) 'ok 'no)
@@ -77,8 +83,9 @@ Note: Test is always true (specialization-tests.scm:XXX)
 
     true
 
-Note: Predicate is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Predicate is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In procedure call:
 
     (scheme#output-port? p)
@@ -93,8 +100,9 @@ Note: Predicate is always true (specialization-tests.scm:XXX)
 
     input/output-port
 
-Note: Test is always true (specialization-tests.scm:XXX) 
-  At toplevel
+Note: Test is always true
+  In file `specialization-tests.scm:XXX',
+  At the toplevel,
   In conditional expression:
 
     (if (scheme#output-port? p) 'ok 'no)
Trap