Open
Description
The following code compiles, and will panic in a confusing way:
proto := bindnode.Prototype(schemaType, nil)
The right way to supply a schema type and infer the Go type is:
proto := bindnode.Prototype(nil, schemaType)
The Go type is passed as a ptrType interface{}
, causing this footgun. Messing up the other way, e.g. proto := bindnode.Prototype(nil, (*MyType)(nil))
wouldn't compile, because the second parameter expects a schema.Type
interface.
We can avoid this footgun by making the bindnode APIs panic if their "Go type" parameter implements the schema.Type
interface. I don't see why anyone would ever implement it on purpose for a Go type used to back a bindnode node. The most likely explanation is that they got the order of the parameters wrong, like I just did.