READ, #- or #+. and *read-suppress*; wrong offset after failed reader conditional

Bug #327790 reported by Tobias C. Rittweiler
2
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Medium
Unassigned

Bug Description

When READ while *READ-SUPPRESS* is T encounters a reader conditional which succeeds,
the file-position afterwards is not the same as if *READ-SUPPRESS* was NIL.

This can make debugging awkward when you switch between *READ-SUPPRESS* values
for debugging purposes.

Test case:

;; Conditional succeeds
(defvar *str1*
"#-q 1 2")

;; Conditional succeeds
(defvar *str2*
"#-q
1
2")

;; Conditional succeeds
(defvar *str3*
"#+sbcl
1
2")

;; Conditional fails
(defvar *str4*
"#+q
1
2")

(defun test-read (string)
  (list
   :expected
   (with-input-from-string (s string)
     (let ((*read-suppress* nil))
       (read s))
     (file-position s))
   :read-supress
   (with-input-from-string (s string)
     (let ((*read-suppress* t))
       (read s))
     (file-position s))))

(values (test-read *str1*)
            (test-read *str2*)
            (test-read *str3*)
            (test-read *str*4))

evaluates to

(:EXPECTED 6 :READ-SUPRESS 5),
(:EXPECTED 6 :READ-SUPRESS 5),
(:EXPECTED 9 :READ-SUPRESS 8),
(:EXPECTED 8 :READ-SUPRESS 8)

Changed in sbcl:
importance: Undecided → Medium
status: New → Confirmed
Douglas Katzman (dougk)
Changed in sbcl:
status: Confirmed → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.