Commit 91eb5180 authored by da-woods's avatar da-woods

Fix a bug where fused_to_specific was applied too widely

Fixes https://github.com/cython/cython/issues/3642
parent 0532a091
......@@ -1031,8 +1031,6 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
if scope is None:
# Maybe it's a cimport.
scope = env.find_imported_module(self.module_path, self.pos)
if scope:
scope.fused_to_specific = env.fused_to_specific
else:
scope = env
......
......@@ -484,3 +484,25 @@ def test_fused_in_check():
print(in_check_2(1.0, 2.0))
print(in_check_2[float, double](1.0, 2.0))
print(in_check_3[float](1.0))
### 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