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

Fix syntax depth calculation for begin-for-syntax + define-syntaxes #124

Merged
merged 1 commit into from
May 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cover/strace.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -168,19 +168,21 @@ The module implements code coverage annotations as described in cover.rkt

;; Syntax -> Natural
;; Maxiumum depth of begin-for-syntaxes
(define (get-syntax-depth expr)
(kernel-syntax-case
(disarm expr) #f
(define (get-syntax-depth expr [phase 0])
(kernel-syntax-case/phase
(disarm expr) phase
[(module _ _ mb)
(get-syntax-depth #'mb)]
[(module* _ _ mb)
(get-syntax-depth #'mb)]
[(begin-for-syntax b ...)
(add1 (apply max 1 (map get-syntax-depth (syntax->list #'(b ...)))))]
(add1 (apply max 1 (for/list ([b (in-list (syntax->list #'(b ...)))])
(get-syntax-depth b (add1 phase)))))]
[(define-syntaxes a ...)
2]
[(b ...)
(apply max 1 (map get-syntax-depth (syntax->list #'(b ...))))]
(apply max 1 (for/list ([b (in-list (syntax->list #'(b ...)))])
(get-syntax-depth b phase)))]
[_ 1]))

;; Natural PathString Symbol -> Syntax
Expand Down
6 changes: 6 additions & 0 deletions cover/tests/bfs+define-syntax.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#lang racket/base

(require (for-meta 1 racket/base)
(for-meta 2 racket/base))

(begin-for-syntax (define-syntax x #f))
1 change: 1 addition & 0 deletions cover/tests/do-bfs+module.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
(define-runtime-path-list others
(list "bfs+module-nolex.rkt"
"bfs+module.rkt"
"bfs+define-syntax.rkt"
"lazy-require.rkt"))
(test-case
"begin-for-syntax with modules should be okay"
Expand Down