#893 closed defect (fixed)
problem with type annotations and modules
| Reported by: | megane | Owned by: | |
|---|---|---|---|
| Priority: | critical | Milestone: | 4.9.0 |
| Component: | unknown | Version: | 4.7.x |
| Keywords: | modules types | Cc: | |
| Estimated difficulty: |
Description
(define (baz a) (add1 a))
(define-syntax foo
(ir-macro-transformer
(lambda (e i c)
`((the (procedure (*) fixnum) baz) 1))))
(print (foo))
(module
m
(bar)
(import chicken scheme)
(define-syntax bar
(ir-macro-transformer
(lambda (e i c)
`((the (procedure (*) fixnum) baz) 1)))))
(import m)
(print (bar))
;; $ csc -debug 2 -specialize foo.scm
;; [canonicalized]
;; (##core#callunit "library")
;; (##core#callunit "eval")
;; (##core#undefined)
;; (set! baz (##core#lambda (a1) (add1 a1)))
;; (##core#undefined)
;; (print (let ((g1516 (##core#the (procedure (*) fixnum) #t baz))) (g1516 '1)))
;; (##core#undefined)
;; (##core#undefined)
;; (print (let ((g4041 (##core#the #f #t baz))) (g4041 '1)))
;; ((##sys#implicit-exit-handler))
;; (##core#undefined)
;; Error: invalid type specification: #f
Attachments (1)
Change History (5)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
A simple workaround should be to either inject the symbols (since the doesn't care about their lexical meaning, just about the literal symbol), or use er-macro-transformers.
by , 13 years ago
| Attachment: | 0001-Fix-implicit-renaming-to-avoid-using-core-aliases-di.patch added |
|---|
Proper fix for implicit renames of core aliases
comment:3 by , 13 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Fixed by 1564a4600c69c0db6b9be97bbda518e725121f75
Note:
See TracTickets
for help on using tickets.

The real problem isn't in type annotations. It's the fact that macros look up "primitive aliases" in the environment, which means they lose their original symbol name. Here's a simplified example:
(module m (bar) (import chicken scheme) (define-syntax bar (ir-macro-transformer (lambda (e r c) '(quote *))))) (import m) (assert (eq? '* (bar)))This assertion should be true, but it isn't. If you
(print (bar)), it'll show#%*which is wrong.##sys#strip-syntaxcan't strip the syntax off {{#%*}} because it's not a gensym, and it might actually be the real symbol the user typed, so we can't just resolve that back to*again.