#518 closed defect (fixed)
strip-syntax returns wrong value for renamed symbols exported form a module
Reported by: | Moritz Heidkamp | Owned by: | sjamaan |
---|---|---|---|
Priority: | major | Milestone: | 4.9.0 |
Component: | unknown | Version: | 4.6.x |
Keywords: | Cc: | ||
Estimated difficulty: |
Description
Stripping syntax from symbols in a macro that have previously been renamed and happen to have the same name as a symbol exported by the module the macro is defined in returns the symbol prefixed with the module name. This is particularly annoying with IR macros which rename all symbols implicitly and thus this problem is likely to occur.
The problem can be reproduces using the following program. It outputs "no: foo#baz" when it should actually output "yes: baz".
(module foo ;; not exporting baz makes it work as expected (bar baz) (import chicken scheme) (define baz 'qux) (define-syntax bar (er-macro-transformer (lambda (x r c) (let ((e (strip-syntax (r (cadr x))))) (if (eq? 'baz e) (display "yes: ") (display "no: ")) (display e) '(void))))) ) (import foo) (bar baz)
Change History (11)
comment:1 Changed 14 years ago by
Owner: | set to sjamaan |
---|---|
Status: | new → accepted |
comment:2 Changed 14 years ago by
comment:4 Changed 14 years ago by
hm, this appears to break tests/compiler-test.scm because the "assert" and "not" macros are expanding to "bar" instead of "foo#bar".
This suggests another problem with core primitives, too:
(print (strip-syntax '#%+)) (print (strip-syntax 'foo#bar)) (module foo (bar) (import chicken scheme) (define bar 1)) (print (strip-syntax '#%+)) (print (strip-syntax 'foo#bar))
Output:
#%+ foo#bar + bar
I don't know if this should be possible or not, but if not then we should have a long, hard look at how things work right now. Putting system properties on non-gensymed symbols is probably a bad idea if it causes such issues.
comment:5 Changed 14 years ago by
The fix for #444 could be rolled back and the code simplified (and made slightly faster) if we also set ##core#real-name
in ##sys#primitive-alias
. It saves us one property access call in ##sys#strip-syntax
comment:6 Changed 14 years ago by
Actually, it's quote which strips syntax in the test.
If you remove strip-syntax in the example code in my previous comment, you'll notice that when compiled, the output is the same. When interpreted, it is not. This should probably be fixed.
Why does quote not strip syntax in the same way in the compiler as in the interpreter?
comment:7 Changed 14 years ago by
Another, hopefully better fix at caa54d2 in expander-simplifications. Need to fix quasiquotation first, then this can be tested properly
comment:8 Changed 14 years ago by
The remaining problem with core primitives is now fixed too, in 39cf6a5 (also expander-simplifications).
All testcases in this ticket now respond with the expected output!
comment:9 Changed 14 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
This looks related to #444