gopherdata / gophernotes

The Go kernel for Jupyter notebooks and nteract.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error instantiating recursive type

RafalSkolasinski opened this issue · comments

When trying to create a simple graph structure - a struct containing a slice of itself - I am getting problems in gophernotes.

Same works fine in just plain go file.

Code:

package main

import "fmt"

type Item struct {
    Name               string
    Children           []Item
}

graph := Item{
    Name: "my-name",
    Children: []Item{
        {Name: "other-name"},
    },
}

throws error (warning?)

reflect.Value.Convert: value of type []struct { Name string; Children []xreflect.Forward } cannot be converted to type []xreflect.Forward

There are known limitations on recursive types, because they are emulated: the reflect package cannot create them.
Yet, this should be one of the supported cases... thanks for pointing out, I will investigate

Would consider adding some warning in the readme for a meantime. It was very confusing.

True. README.md updated.

Fixed in commit 39e156a