Skip to content
This repository has been archived by the owner on Nov 4, 2023. It is now read-only.

List(List(struct)) Appears to be broken. #21

Open
c00w opened this issue Apr 3, 2014 · 6 comments
Open

List(List(struct)) Appears to be broken. #21

c00w opened this issue Apr 3, 2014 · 6 comments

Comments

@c00w
Copy link

c00w commented Apr 3, 2014

I'm using a List(List(Signature)) where

struct Signature {                                                              
    key @0: Data;                                                               
    signature @1: Data;                                                         
}  

and the generated code cannot compile

capnp compile -ogo src/libnode/message.capnp
go install libnode
# libnode
src/libnode/message.capnp.go:1033: cannot range over s.ToArray() (type *[]capn.Object)
Makefile:21: recipe for target 'pkg/linux_amd64/libnode.a' failed
@glycerine
Copy link
Contributor

I can't reproduce this on my branch. @c00w, I may be able to help if you could you provide minimal set of source files that reproduces the problem against my branch (which contains many bug fixes). Here is what appears to work for me:


jaten@i7:~/go/message:master$ cat Makefile
message.capnp.go: message.capnp
    capnp compile -ogo message.capnp
    go build
    go install
jaten@i7:~/go/message:master$ cat message.capnp
@0x8005a1cd963ae761;

using Go = import "go.capnp";
$Go.package("main");
$Go.import("../message");


struct Signature {
    key @0: Data;
    signature @1: Data;
}

struct LL {
   ll @0: List(List(Signature));
}
jaten@i7:~/go/message:master$ cat go.capnp 
@0xd12a1c51fedd6c88;
annotation package(file) :Text;
annotation import(file) :Text;
$import("github.com/glycerine/go-capnproto");
$package("capn");

jaten@i7:~/go/message:master$ cat usemsg.go
cat usemsg.go
package main

import (
    "fmt"

    "github.com/glycerine/go-capnproto"
)

func main() {
    seg := capn.NewBuffer(nil)
    ll := NewRootLL(seg)
    fmt.Printf("sig = %#v\n", ll)
}
jaten@i7:~/go/message:master$ make
capnp compile -ogo message.capnp
go build
go install
jaten@i7:~/go/message:master$ ./message
./message
sig = main.LL{Segment:(*capn.Segment)(0xc2100362d0), off:8, length:0, datasz:0, ptrs:1, typ:0x1, flags:0x0}
jaten@i7:~/go/message:master$

@c00w
Copy link
Author

c00w commented Apr 4, 2014

So I switched to your code already. I didn't test List(List(struct)) with your code however.

The non minimal broken file was

using Go = import "../github.com/jmckaskill/go-capnproto/go.capnp";
$Go.package("libnode");
$Go.import("libnode");

@0xf5151606f45c93ef;

struct Signature {
    key @0: Data;
    signature @1: Data;
}

struct Time {
    #UTC
    seconds @0: UInt64;
    nanoSeconds @1: UInt32;
}

struct TransactionChange {
    source @0: Data;
    destination @1: Data;
    amount @2: UInt64;
}

struct LocationChange {
    account @0: Data;
    location @1: Text;
}

struct KeyChange {
    account @0: Data;
    newkeys @1: List(Data);
}

struct DropChange {
    account @0: Data;
}

enum TimeVote {
    constant @0;
    increase @1;
    decrease @2;
}

struct TimeChange {
    vote @0: TimeVote;
}

struct Change {

    authorization @0: List(Signature);
    created @1: Time;

    type :union {
         transaction @2 :TransactionChange;
         location @3 :LocationChange;
         key @4: KeyChange;
         drop @5: DropChange;
         time @6: TimeChange;

    }
}

struct Vote {
    votes @0: List(Change);
    time @1: Time;
    authorization @2: List(List(Signature));
}

struct Message {
    union {
        vote @0: Vote;
        change @1: Change;
    }
}

@c00w
Copy link
Author

c00w commented Apr 4, 2014

It appears to also be broken on your branch.

@glycerine
Copy link
Contributor

Hi Colin,
Your schema compiles fine for me.
I note that you have this line in your schema:

 using Go = import "../github.com/jmckaskill/go-capnproto/go.capnp";

which suggests that you aren't actually using my branch, or may be mixing the two different branches together, which is unlikely to work.

@c00w
Copy link
Author

c00w commented Apr 4, 2014

That's probably it. I'm using your branch now with a different
configuration and it is working fine.
On Apr 4, 2014 3:30 PM, "Jason E. Aten, Ph.D." [email protected]
wrote:

Hi Colin,
Your schema compiles fine for me.
I note that you have this line in your schema:

using Go = import "../github.com/jmckaskill/go-capnproto/go.capnp";

which suggests that you may you aren't actually using my branch, or may be
mixing the two different branches together, which is unlikely to work.


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-39602483
.

@glycerine
Copy link
Contributor

Hey Colin,
my bad, I was re-compilng but not re-installing capnpc-go. I hit exactly your issue when I actually re-installed capnpc-go. The problem has been fixed now on the mainline of my repo. It was caused by recent JSON contribution work that I merged before it was really ready to go. Again, my apologies.
Jason

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants