Methods with two outputs are expected to return an error, methods aren't visible from python
- Ngôn ngữ chính
- Go
- Star
- 2.3k
- Fork
- 136
- Merge trung bình
- 14 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
Hi, I'm trying to build this project, https://github.com/holiman/uint256, but I've run into multiple issues:
Suppose we have a function with multiple outputs: `func (z *Int) AddOverflow(x, y *Int) (*Int, bool)`, bind expects second argument to be an `error` and outputs the following `gopy: second result value must be of type error`.
To reproduce, minimized testcase:
```go
package uint256
import (
"math/bits"
)
type Int [4]uint64
func NewInt(val uint64) *Int {
z := &Int{}
z.SetUint64(val)
return z
}
func (z *Int) SetUint64(x uint64) *Int {
z[3], z[2], z[1], z[0] = 0, 0, 0, x
return z
}
func (z *Int) AddOverflow(x, y *Int) (*Int, bool) {
var carry uint64
z[0], carry = bits.Add64(x[0], y[0], 0)
z[1], carry = bits.Add64(x[1], y[1], carry)
z[2], carry = bits.Add64(x[2], y[2], carry)
z[3], carry = bits.Add64(x[3], y[3], carry)
return z, carry != 0
}
```
The second issue I'm having is that after compiling the project, public methods of type `Int` aren't exposed to Python, e.g. the following code won't run:
```python
from uint256_py import uint256
x, y, z = uint256.NewInt(123), uint256.NewInt(456), uint256.NewInt(0)
z.Add(x, y) # doesn't work, method isn't visible
```
I suspect this has something to do with `Int` being represented as an array `[4]uint64`.
Versions I'm using: Go 1.21.3 & Python 3.11.5
It seemed related to #315, so I've run this in docker with Go 1.19.5 & Python3.10.12 but the issue persisted.
Thank you.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với package Go được tối giản và import Python cùng lệnh gọi phương thức được tạo như trong issue. Kiểm tra cách gopy xử lý nhiều giá trị trả về và các phương thức trên các kiểu dựa trên array; công việc được hoàn thành khi testcase liên kết kết quả (*Int, bool) và cung cấp các phương thức của Int cho Python.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go, python
- Lĩnh vực
- developer-experience, tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 32/100