racket / syntax-color

Other
8 stars 16 forks source link

Consistent contract error in scribble-lexer test #3

Closed samth closed 8 years ago

samth commented 9 years ago

For example: http://drdr.racket-lang.org/32412/racket/share/pkgs/syntax-color-test/tests/syntax-color/scribble-lexer.rkt

This error started happening when @rfindler tightened contract checking in racket/racket@725536b8b425966a0d70d4a44640cbc1e73aaa50, so the bug was almost certainly there before.

rfindler commented 8 years ago

Here's a reduced form of the test case. This (I think(?) correctly) binds start and end to 1 and 2:

> (let ()
    (define 3ary-lexer (make-scribble-inside-lexer #:command-char #\@))
    (define in (open-input-string "\\"))
    (port-count-lines! in)
    (define-values (txt type paren start end backup new-mode)
      (3ary-lexer in 0 #f))
    (printf "start ~s end ~s\n" start end))
start 1 end 2

But changing the command character to ^ produces 1 and 1.

> (let ()
    (define 3ary-lexer (make-scribble-inside-lexer #:command-char #\^))
    (define in (open-input-string "\\"))
    (port-count-lines! in)
    (define-values (txt type paren start end backup new-mode)
      (3ary-lexer in 0 #f))
    (printf "start ~s end ~s\n" start end))
start 1 end 1

Note that you need to run this from "inside" syntax-color/scribble-lexer or else the contract checking will kick in and you won't see a super-helpful error message.