You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while the maps are useful to iterate to export the enum values, the fact that BarEnum is a basic type with functions on it causes it to be exported as a GoInterface, and so not comparable as the base type.
This is fine. I noticed that if the type implements starlark.Value it can be passed through verbatim. I did this (adding Type, Freeze, Truth, Hash and CompareSameType implementations to BarEnum) and found that the enum values I was exporting were now comparable, but they still didn't compare properly with the Bar field of the Foo struct.
Digging a little deeper, it seems for member fields of structs you call toValue() for the field. This skips the 'does it implement starlark.Value, then pass it through verbatim' check. My case seems to work if I change the line:
The text was updated successfully, but these errors were encountered:
jazzy-crane
changed the title
Nested values implementing starlark.Value
Struct fields implementing starlark.Value are not passed through verbatime as starlark.Value
Jan 7, 2019
jazzy-crane
changed the title
Struct fields implementing starlark.Value are not passed through verbatime as starlark.Value
Struct fields implementing starlark.Value are not passed through verbatim as starlark.Value
Jan 7, 2019
This also happens if you convert.ToValue a map[string]starlark.Value - the starlark.Value values get wrapped in a starlight interface. Same issue with toValue and ToValue
chasehensel
added a commit
to chasehensel/starlight
that referenced
this issue
Jul 6, 2020
I'm not sure how best to explain this, but I'll give it a go. Please ping back if you need more details.
I'm looking at using starlight against some Go structs generated from proto definitions by protoc.
As an example:
I would then pass in the values of BarEnum in my
Unfortunately the function is returning false. Digging deeper it seems that what protoc generates for BarEnum looks something like this:
while the maps are useful to iterate to export the enum values, the fact that BarEnum is a basic type with functions on it causes it to be exported as a GoInterface, and so not comparable as the base type.
This is fine. I noticed that if the type implements starlark.Value it can be passed through verbatim. I did this (adding Type, Freeze, Truth, Hash and CompareSameType implementations to BarEnum) and found that the enum values I was exporting were now comparable, but they still didn't compare properly with the Bar field of the Foo struct.
Digging a little deeper, it seems for member fields of structs you call toValue() for the field. This skips the 'does it implement starlark.Value, then pass it through verbatim' check. My case seems to work if I change the line:
Is this fine to do or does it break other cases?
The text was updated successfully, but these errors were encountered: