Skip to content

Commit

Permalink
cs: fix optimizer bug
Browse files Browse the repository at this point in the history
An optimization pass used mostly for inlining did not reqcognize
`quote`, and it could replace a quoted name with a constant-propagated
value.

Closes #3339
  • Loading branch information
mflatt committed Aug 8, 2020
1 parent 980a9fb commit 4f02901
Show file tree
Hide file tree
Showing 7 changed files with 694 additions and 652 deletions.
17 changes: 17 additions & 0 deletions pkgs/racket-test-core/tests/racket/module.rktl
Original file line number Diff line number Diff line change
Expand Up @@ -3342,4 +3342,21 @@ case of module-leve bindings; it doesn't cover local bindings.

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(module regression-test-for-cross-module-inline-quoted-identifier racket/base
(module a racket/base
(provide FOUNDING)
(define-values (FOUNDING) 'FOUNDING))

(module b racket/base
(require (submod ".." a))
(define (f x_2) (eq? x_2 'FOUNDING)) ; quoted `FOUNDING` should not get replaced
(if (f FOUNDING) FOUNDING (raise-user-error 'die)))

(require (submod "." b)))

(parameterize ([current-output-port (open-output-bytes)])
(dynamic-require ''regression-test-for-cross-module-inline-quoted-identifier #f))

;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(report-errs)
3 changes: 2 additions & 1 deletion racket/src/cs/convert.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@
(hash-map k
(lambda (k v)
(list `(quote ,k)
`(quote ,v))))))]
`(quote ,v)))
#t)))]
[(pair? k)
`(cons ,(loop (car k)) ,(loop (cdr k)))]
[(keyword? k)
Expand Down

0 comments on commit 4f02901

Please sign in to comment.