Commit 0888723e authored by daniloaf@daniloaf-PC's avatar daniloaf@daniloaf-PC

Fixing best match removing ambiguity with pointer and reference

parent aea63286
# #
# Pyrex - Types # Pyrex - Types
# #
...@@ -1383,10 +1384,12 @@ class CReferenceType(CType): ...@@ -1383,10 +1384,12 @@ class CReferenceType(CType):
if other_type is error_type: if other_type is error_type:
return 1 return 1
if other_type.is_ptr: if other_type.is_ptr:
if other_type.base_type == self.base_type: return 0
return 1 #print self, other_type
else: #if other_type.base_type == self.base_type:
pass # return 1
#else:
# pass
#TODO: should send a warning message: initialization from incompatible pointer type (in C/C++) #TODO: should send a warning message: initialization from incompatible pointer type (in C/C++)
if other_type == self.base_type: if other_type == self.base_type:
return 1 return 1
...@@ -2240,8 +2243,9 @@ def best_match(args, functions, pos): ...@@ -2240,8 +2243,9 @@ def best_match(args, functions, pos):
src_type = args[i].type src_type = args[i].type
dst_type = func_type.args[i].type dst_type = func_type.args[i].type
if dst_type.assignable_from(src_type): if dst_type.assignable_from(src_type):
#print src_type, src_type.is_pyobject, dst_type, dst_type.is_pyobject if src_type == dst_type or (dst_type.is_reference and \
if src_type == dst_type or (dst_type.is_reference and src_type == dst_type.base_type): src_type == dst_type.base_type) or \
dst_type.same_as(src_type):
pass # score 0 pass # score 0
elif is_promotion(src_type, dst_type): elif is_promotion(src_type, dst_type):
score[2] += 1 score[2] += 1
......
...@@ -311,11 +311,11 @@ class Scope(object): ...@@ -311,11 +311,11 @@ class Scope(object):
entry.in_cinclude = self.in_cinclude entry.in_cinclude = self.in_cinclude
if name: if name:
entry.qualified_name = self.qualify_name(name) entry.qualified_name = self.qualify_name(name)
# if name in entries and self.is_cpp(): if name in entries and self.is_cpp():
# entries[name].overloaded_alternatives.append(entry) entries[name].overloaded_alternatives.append(entry)
# else: else:
# entries[name] = entry entries[name] = entry
entries[name] = entry # entries[name] = entry
entry.scope = self entry.scope = self
entry.visibility = visibility entry.visibility = visibility
return entry return entry
......
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