Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
85989669
Commit
85989669
authored
May 04, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ambiguous overload scoring error
parent
b5b00d26
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+8
-5
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+16
-0
tests/run/shapes.h
tests/run/shapes.h
+6
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
85989669
...
...
@@ -3467,7 +3467,7 @@ def best_match(args, functions, pos=None, env=None):
elif
((
src_type
.
is_int
and
dst_type
.
is_int
)
or
(
src_type
.
is_float
and
dst_type
.
is_float
)):
score
[
2
]
+=
abs
(
dst_type
.
rank
+
(
not
dst_type
.
signed
)
-
(
src_type
.
rank
+
(
not
src_type
.
signed
)))
(
src_type
.
rank
+
(
not
src_type
.
signed
)))
+
1
elif
not
src_type
.
is_pyobject
:
score
[
1
]
+=
1
else
:
...
...
@@ -3482,10 +3482,13 @@ def best_match(args, functions, pos=None, env=None):
if
possibilities
:
possibilities
.
sort
()
if
len
(
possibilities
)
>
1
and
possibilities
[
0
][
0
]
==
possibilities
[
1
][
0
]:
if
pos
is
not
None
:
error
(
pos
,
"ambiguous overloaded method"
)
return
None
if
len
(
possibilities
)
>
1
:
score1
=
possibilities
[
0
][
0
]
score2
=
possibilities
[
1
][
0
]
if
score1
==
score2
:
if
pos
is
not
None
:
error
(
pos
,
"ambiguous overloaded method"
)
return
None
function
=
possibilities
[
0
][
-
1
]
...
...
tests/run/cpp_classes.pyx
View file @
85989669
...
...
@@ -7,6 +7,9 @@ __doc__ = u"""
12.0
>>> test_square_area(15)
(225.0, 225.0)
>>> test_overload_bint_int()
202
201
"""
cdef
extern
from
"shapes.h"
namespace
"shapes"
:
...
...
@@ -23,6 +26,8 @@ cdef extern from "shapes.h" namespace "shapes":
int
height
Rectangle
()
Rectangle
(
int
,
int
)
int
method
(
int
)
int
method
(
bint
)
cdef
cppclass
Square
(
Rectangle
):
int
side
...
...
@@ -43,6 +48,17 @@ def test_rect_area(w, h):
finally
:
del
rect
def
test_overload_bint_int
():
cdef
Rectangle
*
rect1
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect2
=
new
Rectangle
(
10
,
20
)
try
:
print
rect1
.
method
(
<
int
>
2
)
print
rect2
.
method
(
<
bint
>
True
)
finally
:
del
rect1
del
rect2
def
test_square_area
(
w
):
cdef
Square
*
sqr
=
new
Square
(
w
)
cdef
Rectangle
*
rect
=
sqr
...
...
tests/run/shapes.h
View file @
85989669
...
...
@@ -23,9 +23,15 @@ namespace shapes {
this
->
width
=
width
;
this
->
height
=
height
;
}
float
area
()
{
return
width
*
height
;
}
int
width
;
int
height
;
int
method
(
int
arg
)
{
return
width
*
height
+
arg
;
}
};
class
Square
:
public
Rectangle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment