This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Problem with modules compiled with --full-tailcalls


Hi,

While porting some code that ran with kawa 1.7 to kawa 1.7.91, I noticed a
problem with --full-tailcalls. It seems to be related to a (somewhat) recent
optimization to infer the type of variables declared with a let. Take the
following two modules:

;; -----------------------------------------
(module-name <A>)

(define (foo x)
  (if (< x 0)
      x
      (- x)))
;; -----------------------------------------
(module-name <B>)
(require <A>)

(define (test)
  (let ((x (foo 4)))
    (format #t "x = ~S~%" x)))
;; -----------------------------------------

If module A is compiled with --full-tailcalls, the "foo" function becomes a
Java static method that returns "void" instead of Object. When module B is
compiled, you get the following compile-time error:

testB.scm:5:3: internal compile error - caught java.lang.Error: popType
called
with empty stack B.testB$X(gnu.mapping.CallContext)void
java.lang.Error: popType called with empty stack
B.tesBt$X(gnu.mapping.CallContext)void
        at
gnu.mapping.WrappedException.wrapIfNeeded(WrappedException.java:104)
        at gnu.expr.Compilation.compile(Compilation.java:908)
        at gnu.expr.Compilation.compileToFiles(Compilation.java:939)
        at kawa.lang.CompileFile.compile_to_files(CompileFile.java:70)
        at kawa.repl.processArgs(repl.java:407)
        at kawa.repl.main(repl.java:657)
Caused by: java.lang.Error: popType called with empty stack
B.testB$X(gnu.mapping.CallContext)void
        at gnu.bytecode.CodeAttr.popType(CodeAttr.java:307)
        at gnu.bytecode.CodeAttr.emitStore(CodeAttr.java:1192)
        at gnu.expr.Declaration.compileStore(Declaration.java:242)

Dominique Boucher



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]