Commit 2a6aa2ef authored by da-woods's avatar da-woods Committed by Stefan Behnel

Fix a bug where fused_to_specific was applied too widely

Fixes https://github.com/cython/cython/issues/3642
parent 22f62fe1
...@@ -1023,8 +1023,6 @@ class CSimpleBaseTypeNode(CBaseTypeNode): ...@@ -1023,8 +1023,6 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
if scope is None: if scope is None:
# Maybe it's a cimport. # Maybe it's a cimport.
scope = env.find_imported_module(self.module_path, self.pos) scope = env.find_imported_module(self.module_path, self.pos)
if scope:
scope.fused_to_specific = env.fused_to_specific
else: else:
scope = env scope = env
......
...@@ -400,3 +400,26 @@ def test_composite(fused_composite x): ...@@ -400,3 +400,26 @@ def test_composite(fused_composite x):
return x return x
else: else:
return 2 * x return 2 * x
### see GH3642 - presence of cdef inside "unrelated" caused a type to be incorrectly inferred
cdef unrelated(cython.floating x):
cdef cython.floating t
cdef handle_float(float* x): return 'float'
cdef handle_double(double* x): return 'double'
def convert_to_ptr(cython.floating x):
"""
>>> convert_to_ptr(1.0)
'double'
>>> convert_to_ptr['double'](1.0)
'double'
>>> convert_to_ptr['float'](1.0)
'float'
"""
if cython.floating is float:
return handle_float(&x)
elif cython.floating is double:
return handle_double(&x)
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