diff --git a/collects/macro-debugger/model/reductions.rkt b/collects/macro-debugger/model/reductions.rkt index 2d05d7b..92f5b63 100644 --- a/collects/macro-debugger/model/reductions.rkt +++ b/collects/macro-debugger/model/reductions.rkt @@ -135,7 +135,7 @@ [#:with-visible-form [#:left-foot] [#:set-syntax (stx-car (stx-cdr #'?form))] - [#:step 'macro]] + [#:step 'macro]] ;; FIXME: 'untag-expr [#:pass2] [#:set-syntax (stx-car (stx-cdr oldform))] [#:rename ?form untag])] @@ -199,7 +199,8 @@ srenames 'rename-lsv] [#:binders #'(?svars ... ?vvars ...)] - [BindSyntaxes (?srhs ...) srhss] + [#:when (pair? srhss) ;; otherwise, we're coming from a block expansion + [BindSyntaxes (?srhs ...) srhss]] ;; If vrenames is #f, no var bindings to rename [#:when vrenames [#:rename (((?vvars ?vrhs) ...) . ?body) vrenames 'rename-lsv] diff --git a/collects/tests/macro-debugger/tests/hiding.rkt b/collects/tests/macro-debugger/tests/hiding.rkt index 9033101..e0aa076 100644 --- a/collects/tests/macro-debugger/tests/hiding.rkt +++ b/collects/tests/macro-debugger/tests/hiding.rkt @@ -55,27 +55,29 @@ (test-trivial-hiding/id (let-values ([(x) *]) *)) (test-trivial-hiding/id (letrec-values ([(x) *]) *))) (test-suite "Blocks" + ;; Internal definitions no longer expand into straightforward letrec exprs; + ;; now they can also produce multiple nested lets/letrec forms (test-trivial-hiding/id (lambda (x y) x y)) (test-trivial-hiding (lambda (x y z) (begin x y) z) (lambda (x y z) x y z)) (test-trivial-hiding (lambda (x y z) x (begin y z)) (lambda (x y z) x y z)) (test-trivial-hiding (lambda (x) (define-values (y) x) y) - (lambda (x) (letrec-values ([(y) x]) y))) + (lambda (x) (let-values ([(y) x]) y))) (test-trivial-hiding (lambda (x) (begin (define-values (y) x)) y) - (lambda (x) (letrec-values ([(y) x]) y))) + (lambda (x) (let-values ([(y) x]) y))) (test-trivial-hiding (lambda (x) (begin (define-values (y) x) y) x) - (lambda (x) (letrec-values ([(y) x]) y x))) + (lambda (x) (let-values ([(y) x]) y x))) (test-trivial-hiding (lambda (x) (id (define-values (y) x)) x) - (lambda (x) (letrec-values ([(y) x]) x))) + (lambda (x) (let-values ([(y) x]) x))) (test-trivial-hiding (lambda (x) (id (begin (define-values (y) x) x))) - (lambda (x) (letrec-values ([(y) x]) x))) + (lambda (x) (let-values ([(y) x]) x))) (test-trivial-hiding (lambda (x) (define-values (y) (id x)) y) - (lambda (x) (letrec-values ([(y) x]) y))) + (lambda (x) (let-values ([(y) x]) y))) (test-trivial-hiding (lambda (x y) x (id y)) (lambda (x y) x y)) (test-trivial-hiding (lambda (x) (define-values (y) (id x)) y) - (lambda (x) (letrec-values ([(y) x]) y)))) + (lambda (x) (let-values ([(y) x]) y)))) #| ;; Old hiding mechanism never did letrec transformation (unless forced) (test-suite "Block normalization" @@ -123,17 +125,18 @@ (test-T-hiding (id (Tid x)) (id x))) (test-suite "Blocks" + ;; See note about about internal definition expansion (test-T-hiding/id (lambda (x y) x y)) (test-T-hiding (lambda (x y z) (begin x y) z) (lambda (x y z) x y z)) (test-T-hiding (lambda (x y z) x (begin y z)) (lambda (x y z) x y z)) (test-T-hiding (lambda (x) (define-values (y) x) y) - (lambda (x) (letrec-values ([(y) x]) y))) + (lambda (x) (let-values ([(y) x]) y))) (test-T-hiding (lambda (x) (begin (define-values (y) x)) y) - (lambda (x) (letrec-values ([(y) x]) y))) + (lambda (x) (let-values ([(y) x]) y))) (test-T-hiding (lambda (x) (begin (define-values (y) x) y) x) - (lambda (x) (letrec-values ([(y) x]) y x))) + (lambda (x) (let-values ([(y) x]) y x))) (test-T-hiding (lambda (x) (id x)) (lambda (x) (id x))) (test-T-hiding (lambda (x) (Tid x)) diff --git a/collects/tests/macro-debugger/tests/regression.rkt b/collects/tests/macro-debugger/tests/regression.rkt index 8517fba..c745459 100644 --- a/collects/tests/macro-debugger/tests/regression.rkt +++ b/collects/tests/macro-debugger/tests/regression.rkt @@ -115,21 +115,25 @@ ;; Fixed 5/17/2007 (test-case "hiding: keeping lifts in sync" (let ([freshname (gensym)]) - (eval `(module ,freshname mzscheme - (require (lib "contract.rkt")) - (provide/contract [f (integer? . -> . integer?)] - [c integer?]) + (eval `(module ,freshname racket/base + (require racket/contract) + (provide/contract + [f (-> integer? integer?)] + [c integer?]) (define (f x) (add1 x)) (define c 1))) (let ([rs (parameterize ((macro-policy standard-policy)) (reductions (trace `(module m mzscheme - (require ',freshname) + (require (quote ,freshname)) (define (g y) c) (define h c) (add1 (g 2))))))]) + (printf "not a step:\n~s\n" + (for/or ([s rs]) (and (not (step? s)) s))) (check-pred list? rs) - (check-true (andmap step? rs))))) + (for ([x (in-list rs)]) + (check-true (not (misstep? x))))))) ;; Bug from samth (6/5/2007) ;; problem seems to come from define-syntax -> letrec-syntaxes+values diff --git a/collects/tests/macro-debugger/tests/syntax-basic.rkt b/collects/tests/macro-debugger/tests/syntax-basic.rkt index 5e01601..b35cf08 100644 --- a/collects/tests/macro-debugger/tests/syntax-basic.rkt +++ b/collects/tests/macro-debugger/tests/syntax-basic.rkt @@ -216,9 +216,17 @@ (lambda () 'a (define-values (x) 'b) 'c) [#:steps (rename-lambda (lambda () 'a (define-values (x) 'b) 'c)) - (block->letrec (lambda () (letrec-values ([() (begin 'a (#%app values))] [(x) 'b]) 'c))) - (rename-letrec-values (lambda () (letrec-values ([() (begin 'a (#%app values))] [(x) 'b]) 'c)))] - #:same-hidden-steps)] + (block->letrec (lambda () (letrec-values ([() (begin 'a (values))] [(x) 'b]) 'c))) + (rename-letrec-values + (lambda () (letrec-values ([() (begin 'a (values))] [(x) 'b]) 'c))) + (tag-app (lambda () (letrec-values ([() (begin 'a (#%app values))] [(x) 'b]) 'c))) + ;; FIXME: should have TAG step for transform to nested let-values + ] + [#:hidden-steps + (rename-lambda (lambda () 'a (define-values (x) 'b) 'c)) + (block->letrec (lambda () (letrec-values ([() (begin 'a (values))] [(x) 'b]) 'c))) + (rename-letrec-values + (lambda () (letrec-values ([() (begin 'a (values))] [(x) 'b]) 'c)))])] [#:suite "Top-level begin" diff --git a/collects/tests/macro-debugger/tests/syntax-modules.rkt b/collects/tests/macro-debugger/tests/syntax-modules.rkt index 3297fe2..b5e9aed 100644 --- a/collects/tests/macro-debugger/tests/syntax-modules.rkt +++ b/collects/tests/macro-debugger/tests/syntax-modules.rkt @@ -278,6 +278,13 @@ (if or-part or-part (or 'b))) 'c))) (macro + (module m mzscheme + (#%plain-module-begin + (#%require (for-syntax scheme/mzscheme)) + (let-values ([(or-part) 'a]) + (if or-part or-part (#%expression 'b))) + 'c))) + (macro ;; FIXME: 'untag-expr (module m mzscheme (#%plain-module-begin (#%require (for-syntax scheme/mzscheme)) @@ -313,6 +320,12 @@ (let-values ([(or-part) 'a]) (if or-part or-part (or 'b)))))) (macro + (module m mzscheme + (#%plain-module-begin + (#%require (for-syntax scheme/mzscheme)) + (let-values ([(or-part) 'a]) + (if or-part or-part (#%expression 'b)))))) + (macro ;; FIXME: 'untag-expr (module m mzscheme (#%plain-module-begin (#%require (for-syntax scheme/mzscheme))