This is the mail archive of the kawa@sourceware.org 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]

Strange error message


When I add wrong `toString` method to example from
http://www.gnu.org/software/kawa/Defining-new-classes.html :

$ cat ex.scm
(define-simple-class <2d-vector> ()
 (x type: <double> init-keyword: x:)
 (y type: <double> init-keyword: y:)
 (zero-2d :: <2d-vector> allocation: 'static
  init-value: (make <2d-vector> 0))
 ;; An object initializer (constructor) method.
 ((*init* (x0 :: <double>) (y0 :: <double>))
  (set! x x0)
  (set! y y0))
 ((*init* (xy0 :: <double>))
  ;; Call above 2-argument constructor.
  (invoke-special <2d-vector> (this) '*init* xy0 xy0))
 ;; Need a default constructor as well, for the  (make ..) below.
 ((*init*) #!void)
 ((add (other :: <2d-vector>)) :: <2d-vector>
  ;; Kawa compiles this using primitive Java types!
  (make <2d-vector>
    x: (+ x (slot-ref other 'x))
    y: (+ y (slot-ref other 'y))))
 ((scale (factor :: <double>)) :: <2d-vector>
  (make <2d-vector> x: (* factor x) y: (* factor y)))
 ((toString) :: java.lang.String
    (let ((sbuf :: java.lang.StringBuffer
           (make java.lang.StringBuffer "2d-vector: ")))
      (when (plusp x)
        (sbuf:append (java.lang.Double:toString x))
        (sbuf:append " ")
        (sbuf:append (java.lang.Double:toString y)))
      (*:toString sbuf)))
)


I get strange error message:


$ kawa -C ex.scm
(compiling ex.scm to ex)
ex.scm:10: internal error while compiling ex.scm
java.lang.Error: passing Uninitialized<$N2d$Mnvector> as parameter
       at gnu.bytecode.CodeAttr.emitInvokeMethod(CodeAttr.java:1471)
       at gnu.bytecode.CodeAttr.emitInvokeVirtual(CodeAttr.java:1515)
       at gnu.expr.ApplyExp.compile(ApplyExp.java:392)
       at gnu.expr.ApplyExp.compile(ApplyExp.java:110)
       at gnu.expr.Expression.compileWithPosition(Expression.java:133)
       at gnu.expr.ClassExp.compileMembers(ClassExp.java:522)
       at gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
       at gnu.expr.ClassExp.compileSetField(ClassExp.java:779)
       at gnu.expr.SetExp.compile(SetExp.java:172)
       at gnu.expr.Expression.compileNotePosition(Expression.java:159)
       at gnu.expr.Expression.compileWithPosition(Expression.java:145)
       at gnu.expr.LambdaExp.compileBody(LambdaExp.java:1617)
       at gnu.expr.Compilation.generateBytecode(Compilation.java:2017)
       at gnu.expr.Compilation.process(Compilation.java:1893)
       at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:307)
       at gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:292)
       at kawa.repl.compileFiles(repl.java:718)
       at kawa.repl.processArgs(repl.java:408)
       at kawa.repl.main(repl.java:762)


-- WBR, Yaroslav Kavenchuk


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