Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scribble examples fail to use + correctly #376

Open
zyrolasting opened this issue Sep 27, 2023 · 0 comments
Open

Scribble examples fail to use + correctly #376

zyrolasting opened this issue Sep 27, 2023 · 0 comments

Comments

@zyrolasting
Copy link

zyrolasting commented Sep 27, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant