Scribble examples fail to use `+` correctly
Nobody has claimed this yet.
- Dominant language
- Racket
- Stars
- 250
- Forks
- 102
- Avg merge
- 11d 11h
- Merged PRs (30d)
- 1
Description
I'm on 8.10 [cs], the latest Debian, and am running my code using racket-mode. I have a #lang scribble/manual document that depends on scribble/examples. I'll start with the error.
; +: contract violation
; expected: number?
; given: #f
; Context (plain; to see better errortrace context, re-run with C-u prefix):
; /home/sage/.racket/share/pkgs/scribble-lib/scribble/racket.rkt:1272:26 loop
; /home/sage/.racket/share/pkgs/scribble-lib/scribble/racket.rkt:1272:26 loop
; /home/sage/.racket/share/pkgs/scribble-lib/scribble/racket.rkt:1168:0 do-syntax-ize
; /home/sage/.racket/share/pkgs/scribble-lib/scribble/racket.rkt:1272:26 loop
; /home/sage/.racket/share/pkgs/scribble-lib/scribble/racket.rkt:1272:26 loop
[...]
This @-expression from my code that raises the error. Simpler examples do not reproduce, so let's go with this for now. It appears that the (struct term:ksub term (body) #:transparent) instance fails in this exact composition, where term is just (struct term () #:transparent). I'm omitting other structure definitions to keep this at least somewhat brief.
@demo[
(define (ksub-example . xs)
(with-syntax ([(x ...) xs])
(term:ksub-parse
#'(module #%kernel '#%kernel
(#%module-begin
(#%require '#%kernel
(for-syntax '#%kernel)
(prefix : '#%kernel)
(for-syntax (prefix : '#%kernel)))
x ...)))))
(ksub-example '(#%provide (all-from '#%kernel)))
]
I use this demo macro. Let #:eval be hypothetical.
(define-syntax-rule (demo forms ...)
(examples #:eval (example-evaluator) forms ...))
If you change '(#%provide (all-from '#%kernel))) to #'(#%provide (all-from '#%kernel))), the error goes away. Since scribble-lib/scribble/racket.rkt:1272:26 makes heavy use of syntax-span, I suspect that location information disappears in some nontrivial compositions of quoted code in syntax templates.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Scribble example with scribble/examples and the demo macro, then inspect scribble-lib/scribble/racket.rkt around line 1272 and its use of syntax-span. Compare the quoted and syntax-quoted #%provide forms and determine why the composition produces #f; done means the reported example no longer raises the + contract violation.
Written by the indexing model from the issue text.
Assessment
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100