This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Problem using MyType[] in macros
Hello.
I have just spent the evening reducing my original code down, and
perhaps this is a bug. I can't work it out:
test.macro.scm:
(define (my-helper field-op-expr)
(syntax-case field-op-expr (array int pack java-type)
(((array subtype) java-type)
(with-syntax ((sub-java-type (my-helper (syntax (subtype java-type)))))
(syntax (different-thing sub-java-type))))
;; THIS NEXT CASE is messing things up! commenting it out fixes it
(((array subtype) pack another another2) (syntax ()))
((field-type java-type)
(syntax field-type))))
(define-syntax my-macro
(lambda (class-def)
(syntax-case class-def ()
((_ field-declaration)
(with-syntax ((out (my-helper (syntax (field-declaration java-type)))))
(syntax (display (format "~A~%" 'out))))))))
test.scm:
(my-macro (array int))
Then I'm compiling with:
$ kawa -f test.macros.scm --main -C test.scm && java -cp
.:/usr/local/share/java/kawa.jar test
This is the result I'm getting:
(compiling test.scm)
test.scm:2:1: evaluating syntax transformer 'my-macro' threw
java.lang.ArrayIndexOutOfBoundsException
This is what I get if I comment out that unrelated syntax-case entry:
(compiling test.scm to test)
(different-thing int)
Investigating further with Eclipse's debugger, SyntaxPattern.allocVars
is getting called with varCount = 2 and outer being an array of 8
long, so outer and it's 8 entries don't fit into the new vars array.
The variable outer is [(int), null, null, null, null, null, null,
null] in the debugger.
Hope this helps.
Thanks!
-Bill