Skip to content

Commit 47cb0d4

Browse files
committed
fix bytes->string error
`thing` is defined as a string on L446, so calling `(bytes->string/utf-8 thing)` on L478 would raise a contract error. Test case: trying to read `'\\xDDDD;` in an R6RS module
1 parent 3b19e68 commit 47cb0d4

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

r6rs-lib/r6rs/private/readtable.rkt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,9 @@
475475
16)])
476476
(unless (or (<= 0 v #xD7FF)
477477
(<= #xE000 v #x10FFFF))
478-
(let ([str (bytes->string/utf-8 thing)])
479-
(raise-read-error
480-
(format "out of range escape: `\\x~a;'" (cadr m))
481-
src line col pos (and pos (string-length str)))))
478+
(raise-read-error
479+
(format "out of range escape: `\\x~a;'" (caddr m))
480+
src line col pos (and pos (string-length thing))))
482481
(string->bytes/utf-8 (string (integer->char v))))
483482
(loop (cadddr m))))
484483
t)))))]

r6rs-test/tests/r6rs/exceptions.sls

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@
8686
(test v '(out in out in)))
8787

8888

89+
(test/output
90+
(guard (con
91+
((violation? con)
92+
(display (condition-message con))
93+
'violation))
94+
(read (open-string-input-port "\\xDDDD;")))
95+
'violation
96+
"out of range escape: `\\xDDDD;'")
8997

9098
;;
9199
))

0 commit comments

Comments
 (0)