Commit 389ba104 authored by scoder's avatar scoder Committed by GitHub

Fix a bug where "fused_to_specific" was applied too widely (GH-3654)

Fixes https://github.com/cython/cython/issues/3642
parents 12c7237b f808448f
......@@ -1032,8 +1032,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,26 @@ 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 = 1
return 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