Summary

problem with type annotations and modules

Metadata

Attachments

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

Changes and comments

[2012-08-09 20:22:37 UTC] sjamaan wrote:

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-syntax can'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.

[2012-08-09 20:39:30 UTC] sjamaan wrote:

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.

[2012-08-09 21:01:35 UTC] sjamaan attached 0001-Fix-implicit-renaming-to-avoid-using-core-aliases-di.patch (description=Proper fix for implicit renames of core aliases)

[2012-08-10 15:21:11 UTC] mario changed status from new to closed

[2012-08-10 15:21:11 UTC] mario set resolution to fixed

[2012-08-10 15:21:11 UTC] mario wrote:

Fixed by 1564a4600c69c0db6b9be97bbda518e725121f75

[2012-09-24 21:47:48 UTC] felix changed milestone from 4.8.0 to 4.9.0

[2012-09-24 21:47:48 UTC] felix wrote:

Milestone 4.8.0 deleted