Commit 59c4b922 authored by Robert Bradshaw's avatar Robert Bradshaw

Type inference fixes.

parent 9a688de2
...@@ -4954,11 +4954,10 @@ class CallNode(ExprNode): ...@@ -4954,11 +4954,10 @@ class CallNode(ExprNode):
if func_type.is_ptr: if func_type.is_ptr:
func_type = func_type.base_type func_type = func_type.base_type
if func_type.is_cfunction: if func_type.is_cfunction:
if hasattr(self.function, 'entry'): if getattr(self.function, 'entry', None) and hasattr(self, 'args'):
alternatives = self.function.entry.all_alternatives() alternatives = self.function.entry.all_alternatives()
arg_types = [arg.infer_type(env) for arg in self.args] arg_types = [arg.infer_type(env) for arg in self.args]
func_entry = PyrexTypes.best_match( func_entry = PyrexTypes.best_match(arg_types, alternatives)
arg_types, alternatives, None, env)
if func_entry: if func_entry:
func_type = func_entry.type func_type = func_entry.type
if func_type.is_ptr: if func_type.is_ptr:
...@@ -5185,7 +5184,7 @@ class SimpleCallNode(CallNode): ...@@ -5185,7 +5184,7 @@ class SimpleCallNode(CallNode):
alternatives = overloaded_entry.all_alternatives() alternatives = overloaded_entry.all_alternatives()
entry = PyrexTypes.best_match( entry = PyrexTypes.best_match(
[arg.type for arg in args], alternatives, self.pos, env) [arg.type for arg in args], alternatives, self.pos, env, args)
if not entry: if not entry:
self.type = PyrexTypes.error_type self.type = PyrexTypes.error_type
......
...@@ -4021,7 +4021,7 @@ def is_promotion(src_type, dst_type): ...@@ -4021,7 +4021,7 @@ def is_promotion(src_type, dst_type):
return src_type.is_float and src_type.rank <= dst_type.rank return src_type.is_float and src_type.rank <= dst_type.rank
return False return False
def best_match(arg_types, functions, pos=None, env=None): def best_match(arg_types, functions, pos=None, env=None, args=None):
""" """
Given a list args of arguments and a list of functions, choose one Given a list args of arguments and a list of functions, choose one
to call which seems to be the "best" fit for this list of arguments. to call which seems to be the "best" fit for this list of arguments.
...@@ -4114,8 +4114,8 @@ def best_match(arg_types, functions, pos=None, env=None): ...@@ -4114,8 +4114,8 @@ def best_match(arg_types, functions, pos=None, env=None):
for index, (func, func_type) in enumerate(candidates): for index, (func, func_type) in enumerate(candidates):
score = [0,0,0,0] score = [0,0,0,0]
for i in range(min(len(args), len(func_type.args))): for i in range(min(actual_nargs, len(func_type.args))):
src_type = args[i].type src_type = arg_types[i]
dst_type = func_type.args[i].type dst_type = func_type.args[i].type
assignable = dst_type.assignable_from(src_type) assignable = dst_type.assignable_from(src_type)
......
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