Commit 31d50eb9 authored by Stefan Behnel's avatar Stefan Behnel

fix C++ function matching: Entry objects are not ordered

parent d7ed1fcd
...@@ -2546,7 +2546,7 @@ def best_match(args, functions, pos=None): ...@@ -2546,7 +2546,7 @@ def best_match(args, functions, pos=None):
possibilities = [] possibilities = []
bad_types = [] bad_types = []
for func, func_type in candidates: for index, (func, func_type) in enumerate(candidates):
score = [0,0,0] score = [0,0,0]
for i in range(min(len(args), len(func_type.args))): for i in range(min(len(args), len(func_type.args))):
src_type = args[i].type src_type = args[i].type
...@@ -2566,14 +2566,14 @@ def best_match(args, functions, pos=None): ...@@ -2566,14 +2566,14 @@ def best_match(args, functions, pos=None):
bad_types.append((func, error_mesg)) bad_types.append((func, error_mesg))
break break
else: else:
possibilities.append((score, func)) # so we can sort it possibilities.append((score, index, func)) # so we can sort it
if possibilities: if possibilities:
possibilities.sort() possibilities.sort()
if len(possibilities) > 1 and possibilities[0][0] == possibilities[1][0]: if len(possibilities) > 1 and possibilities[0][0] == possibilities[1][0]:
if pos is not None: if pos is not None:
error(pos, "ambiguous overloaded method") error(pos, "ambiguous overloaded method")
return None return None
return possibilities[0][1] return possibilities[0][-1]
if pos is not None: if pos is not None:
if len(bad_types) == 1: if len(bad_types) == 1:
error(pos, bad_types[0][1]) error(pos, bad_types[0][1])
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment