Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions py/method.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ func newBoundMethod(name string, fn interface{}) (Object, error) {
m.method = func(_ Object) (Object, error) {
return f()
}
// M__index__() (Int, error)
case func() (Int, error):
m.method = func(_ Object) (Object, error) {
return f()
}
// M__add__(other Object) (Object, error)
case func(Object) (Object, error):
m.method = func(_ Object, other Object) (Object, error) {
Expand Down
4 changes: 4 additions & 0 deletions py/tests/int.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
assert repr(1000000000000000000000000000000) == "1000000000000000000000000000000"
assert repr(-1000000000000000000000000000000) == "-1000000000000000000000000000000"

doc="index"
assert True.__index__() == 1
assert False.__index__() == 0

doc="test overflow"
assert int("1000000000000000000") == 10**18
assert int("-1000000000000000000") == -(10**18)
Expand Down
Loading