schemify: preserve variable assignment order at module end

A sequence of definitions (or `define-values`) at the end of
a module could get reordered. That only matters for the order
of checks for attempting to assign to a constant, though.
This commit is contained in:
Matthew Flatt 2019-11-26 15:46:25 -07:00
parent 80a29553c9
commit 70459f4105
2 changed files with 9 additions and 8 deletions

View File

@ -3144,13 +3144,15 @@ case of module-leve bindings; it doesn't cover local bindings.
(test #t namespace? (module->namespace ''lang-is-imports-uses-local-expand)))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Check order of checking for redefinition of a constant
(test '(1 2 3)
call-with-continuation-prompt
(lambda ()
(eval (quote (begin (abort-current-continuation (default-continuation-prompt-tag) 1 2 3) 10))))
(default-continuation-prompt-tag)
list)
(let ([e '(module defines-a-spider-struct-type racket/base
(struct spider (legs)))])
(eval e)
(namespace-require ''defines-a-spider-struct-type)
(err/rt-test (eval e)
exn:fail:contract:variable?
#rx"struct:spider"))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@ -243,8 +243,7 @@
(cond
[(null? accum-exprs) '((void))]
[else (reverse accum-exprs)])]
[else (append (reverse accum-exprs)
set-vars)])]
[else (reverse (append set-vars accum-exprs))])]
[else
(define form (car l))
(define schemified (schemify form