From 2009419979a3392b23d21b40731cfece8dc935f9 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Tue, 24 Apr 2007 01:50:09 +0000 Subject: [PATCH] fix read-error reporting for characters that live in no port svn: r6031 --- collects/tests/mzscheme/read.ss | 5 +++++ src/mzscheme/src/error.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/collects/tests/mzscheme/read.ss b/collects/tests/mzscheme/read.ss index 9ea8bc9006..09c02da8ec 100644 --- a/collects/tests/mzscheme/read.ss +++ b/collects/tests/mzscheme/read.ss @@ -951,6 +951,11 @@ (test #\{ syntax-property (read-syntax 'x (open-input-string "{1 2 3}")) 'paren-shape) (test #\{ syntax-property (read-syntax 'x (open-input-string "#{1 2}")) 'paren-shape) +;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Test read error on a character not in any port + +(err/rt-test (read/recursive (open-input-string ";") #\. #f) exn:fail:read?) + ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (report-errs) diff --git a/src/mzscheme/src/error.c b/src/mzscheme/src/error.c index 34b01fe818..6df7de67b0 100644 --- a/src/mzscheme/src/error.c +++ b/src/mzscheme/src/error.c @@ -1323,6 +1323,11 @@ void scheme_read_err(Scheme_Object *port, show_loc = SCHEME_TRUEP(scheme_get_param(scheme_current_config(), MZCONFIG_ERROR_PRINT_SRCLOC)); + /* Via read/recursive, it's possible that the reader will try to + complain about a character that precedes the start of a port. + In that case, pos can be 0. */ + if (!pos) line = col = pos = -1; + if (stxsrc) { Scheme_Object *xsrc;