diff --git a/module/mes/guile.mes b/module/mes/guile.mes index bd2f3bb4..5b5051f4 100644 --- a/module/mes/guile.mes +++ b/module/mes/guile.mes @@ -148,7 +148,7 @@ (set! tell 0) (set! peek-char (lambda () (if (= tell end) (integer->char -1) - (string-ref string (- tell 1))))) + (string-ref string tell)))) (set! read-char (lambda () (if (= tell end) (integer->char -1) (begin diff --git a/tests/guile.test b/tests/guile.test index 0af3b35e..1fa3b114 100755 --- a/tests/guile.test +++ b/tests/guile.test @@ -117,4 +117,10 @@ exit $? (with-input-from-string "X" (lambda () (peek-char)))) +(pass-if-equal "open-input-string peek" + #\X + (let ((port (open-input-string "X"))) + (set-current-input-port port) + (peek-char))) + (result 'report)