-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Third-party imported type method is not callable from fast.Interp.Eval [gomacro repl works] #142
Comments
One more interesting example from attempted workaround
Fails with
It seems that in
something strange happens with typ.ReflectType(), it has |
Sorry for the very late answer. Yes, it's definitely strange because running the same code directly from gomacro repl works: import "github.com/holiman/uint256"
func Foo(x *uint256.Int) int {
return x.Sign()
}
y := uint256.NewInt(123)
Foo(y) produces the following output: // debug: running "go get github.com/holiman/uint256" ...
go: added github.com/holiman/uint256 v1.2.4
// debug: running "go mod tidy" ...
// debug: compiling plugin "/home/max/go/src/gomacro.imports/gomacro_pid_17289/import_1" ...
1 // int |
I am debugging this issue, and it's specific to methods attached to non-struct types. Package type Int [4]uint64 then defines methods with pointer receiver func (z *Int) Sign() int {
// ...
} Which is perfectly legal, but less tested in gomacro than methods attached to structs. Continuing the analysis... |
…y types, named slice types, and all other named non-struct types if generics v2 are disabled
Fixed in commit 960f329 It was a bug in method lookup: it checked for types that cannot have methods and failed early in such case, |
Hi, thanks for cool package!
I was playing around with it and got the following strange problem.
Small example here
It seems I'm successfully importing the library but when I'm trying to use any of uint256.Int methods I get an error.
I also tried using
interp.DeclType
to introduceuint256.Int
type from host to interpreter, with same result. However, if I createuint256.NewInt(123)
in interpreter and use methods in host code it works.I tried the same approach with another simple library
github.com/bits-and-blooms/bitset
and it worked.That makes me think that problem is connected with type aliases (as it's declared as
type Int [4]uint64
).Is this case not supported? Is there any workaround for that?
The text was updated successfully, but these errors were encountered: