bugKawa - Bugs: bug #11822, Problem expanding define-syntax...

 
 

bug #11822: Problem expanding define-syntax macro that uses defmacro macro

Submitted by:  Dean Ferreyra <dferreyra>
Submitted on:  Wed 02 Feb 2005 08:27:54 PM UTC  
 
Category: Scheme languageSeverity: 3 - Normal
Item Group: Unexpected resultStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Fri 25 Mar 2005 10:24:34 PM UTC, comment #7:

I checked in a hopefully-clean patch. (This subsumes the patch I sent you a couple fo days ago.)

I also checked in a testcase derived from your macro3.diff.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue 08 Feb 2005 06:57:55 PM UTC, comment #6:

Per, thanks for the quick responses.

I've pulled your latest CVS changes. I'm still seeing warnings in our code and concomitant run-time exceptions.

I've attached a slightly different example that still exhibits the problem.

Macro mB looks like this:

(define-syntax mB
(syntax-rules ()
((_ type name)
(mA type
((fn o) :: <void>
(simpleAux:init o)
(display (slot-ref o 'x))
(newline) ;; Comment these 2 lines
(display name) ;; and get no warnings
(newline))))))

When compiling, I get these warnings on the uses of "o":

java kawa.repl --warn-undefined-variable --main -C macro.scm
(compiling macro.scm)
macroB.scm:12:25: warning - no declaration seen for o
macroB.scm:13:28: warning - no declaration seen for o

An interesting thing, I think, is that if I comment out the (newline) and (display ...) calls, then the warnings go away and the resulting code works.

Dean Ferreyra <dferreyra>
Tue 08 Feb 2005 07:01:41 AM UTC, comment #5:

I checked in a fix for the macros2.diff test-case.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue 08 Feb 2005 01:27:55 AM UTC, comment #4:

I was able to try out your latest check-ins and things have definitely improved: Half of the warning I was getting have been eliminated while compiling the Merced Systems source.

By the way, as far as I know, we exclusively use (module-static #t) in our sources.

I'm attaching another test case that's still giving me warnings. Here's what the build looks like:

% make new
rm -f *.class
CLASSPATH=.:~/kawa/cvs/kawa-pure/kawa-1.7.91.jar make run
make[1]: Entering directory `/home/dferreyra/kawa/tests'
java kawa.repl --warn-undefined-variable --main -C simple.scm
(compiling simple.scm)
java kawa.repl --warn-undefined-variable --main -C macroA.scm
(compiling macroA.scm)
java kawa.repl --warn-undefined-variable --main -C macroB.scm
(compiling macroB.scm)
java kawa.repl --warn-undefined-variable --main -C macro.scm
(compiling macro.scm)
macro.scm:6:3: warning - no declaration seen for init
java macro
Exception in thread "main" java.lang.ExceptionInInitializerError
Caused by: gnu.mapping.UnboundLocationException: unbound location {ClassType simpleAux}init@c53dce env:#<procedure interaction-environment.1> loc:gnu.mapping.PlainLocation[{ClassType simpleAux}init]
at gnu.mapping.Location.get(Location.java:65)
at macro.$run$(macro.scm:6)
at macro.<clinit>(macro.scm)
make[1]: *** [run] Error 1
make[1]: Leaving directory `/home/dferreyra/kawa/tests'
make: *** [new] Error 2

Anonymous
Mon 07 Feb 2005 09:43:13 PM UTC, comment #3:

I checked in a fix for this.
The testcase still doesn't for for static-module #f - I'm working on that.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Sat 05 Feb 2005 03:54:38 AM UTC, comment #2:

I have a fix for this that works for module-static.
The Kawa CVS site being down makes it a little inconvient to make a patch, but I can if needed.
In any case, I really would like to get the test-case also working for module-static #f, which is harder.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Thu 03 Feb 2005 06:35:14 AM UTC, comment #1:

The problem isn't defmacro per se - the same happens with a define-syntax/syntax-rules in macroA.scm.
I think I understand the problem - it's an interaction of require and how the rewrite-pass figures out a name is a macro. The correct fix that doesn't break other things will need some pondering.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Wed 02 Feb 2005 08:27:54 PM UTC, original submission:

In our source (at Merced Systems) we have a rather complex defmacro macro that is in turn being used by define-syntax macros. This set up compiles and works correctly with a 1.7.90 version of the Kawa compiler, but with a recent CVS pull I'm getting "no declaration seen" warnings on forms appearing in the define-syntax macro and then finally the generated code is incorrect.

I've distilled it down to a small example. One file defines mA:

(defmacro mA (arg)
`',(caar arg))

while another file defines mB that uses mA:

(define-syntax mB
(syntax-rules ()
((_ arg)
(mA ((init) :: <void> (set! x #t))))))

When trying to use mB, I get the following warnings:

java kawa.repl --warn-undefined-variable --main -C macro.scm
(compiling macro.scm)
macroB.scm:8:10: warning - no declaration seen for init
macroB.scm:8:18: warning - no declaration seen for ::

and the generated code tries to resolve init and :: at run-time. Maybe mA is not being expanded in mB?

I've attached the complete example that demonstrates this problem.

Dean Ferreyra <dferreyra>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #2530:  macros3.diff added by dferreyra (1KiB - application/octet-stream - And another example with warnings)
file #2527:  macros2.diff added by None (914B - application/octet-stream - Another example with warnings)
file #2486:  macros.diff added by dferreyra (572B - application/octet-stream - Example that demonstrates this problem)

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 6 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Thu 19 May 2005 04:57:18 PM UTCbothnerOpen/ClosedOpen=>Closed
Fri 25 Mar 2005 10:24:34 PM UTCbothnerStatusNone=>Fixed
Tue 08 Feb 2005 06:57:55 PM UTCdferreyraAttached File-=>Added macros3.diff, #2173
Tue 08 Feb 2005 01:27:55 AM UTCNoneAttached File-=>Added macros2.diff, #2170
Thu 03 Feb 2005 06:35:14 AM UTCbothnerAssigned toNone=>bothner
Wed 02 Feb 2005 08:27:54 PM UTCdferreyraAttached File-=>Added macros.diff, #2146

Back to the top


Powered by Savane 3.1-cleanup1