Opened 14 years ago

Closed 14 years ago

Last modified 12 years ago

#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 sjamaan

Owner: set to sjamaan
Status: newaccepted

comment:2 Changed 14 years ago by sjamaan

This looks related to #444

comment:3 Changed 14 years ago by sjamaan

Please try da667f1 (in expander-simplifications)

comment:4 Changed 14 years ago by sjamaan

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 sjamaan

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 sjamaan

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 sjamaan

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 sjamaan

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 felix winkelmann

Resolution: fixed
Status: acceptedclosed

comment:10 Changed 14 years ago by felix winkelmann

Milestone: 4.7.04.8.0

Milestone 4.7.0 deleted

comment:11 Changed 12 years ago by felix winkelmann

Milestone: 4.8.04.9.0

Milestone 4.8.0 deleted

Note: See TracTickets for help on using tickets.