wit-bindgen-go generate sometimes outputs invalid go code.
Seems to be happening with variants.
I have the following wit
package webidl:my-package;
world my-world {
import my-interface: interface {
variant my-variant {
foo(my-resource),
}
resource my-resource {
my-method: func(param: my-variant);
}
}
}
go run go.bytecodealliance.org/cmd/wit-bindgen-go generate -o internal/ wit
Outputs:
Error formatting file: error in abi.go: 13:34: expected type, found ')'
The actual api.go looks like:
// Code generated by wit-bindgen-go. DO NOT EDIT.
package myinterface
import (
"go.bytecodealliance.org/cm"
)
func lower_MyVariant(v MyVariant) (f0 uint32, f1 uint32) {
f0 = (uint32)(v.Tag())
switch f0 {
case 0: // foo
v1 := cm.Reinterpret[uint32](*v.())
f1 = (uint32)(v1)
}
return
}
My understanding is the *v.() is the problem (I'm new to go)
Something weird I noticed: changing the namespace name from webidl to my-webidl resolves the problem with this specific wit, but not with other wit 🤷
wit-bindgen-go generate sometimes outputs invalid go code.
Seems to be happening with variants.
I have the following wit
go run go.bytecodealliance.org/cmd/wit-bindgen-go generate -o internal/ witOutputs:
Error formatting file: error in abi.go: 13:34: expected type, found ')'The actual api.go looks like:
My understanding is the
*v.()is the problem (I'm new to go)Something weird I noticed: changing the namespace name from
webidltomy-webidlresolves the problem with this specific wit, but not with other wit 🤷