diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 1e9b5e9fa2b..bcc65f9b6c0 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -2805,6 +2805,9 @@ def parse_indexed_fused_cdef(self, env): self.is_fused_index = False return + for i, type in enumerate(specific_types): + specific_types[i] = type.specialize_fused(env) + fused_types = base_type.get_fused_types() if len(specific_types) > len(fused_types): return error(self.pos, "Too many types specified") diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index e0703a13b30..5279a416377 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -57,6 +57,12 @@ def get_fused_types(self, result=None, seen=None, subtypes=None): return None + def specialize_fused(self, env): + if env.fused_to_specific: + return self.specialize(env.fused_to_specific) + + return self + def _get_fused_types(self): """ Add this indirection for the is_fused property to allow overriding diff --git a/tests/run/fused_types.pyx b/tests/run/fused_types.pyx index 53e731599c5..c452157476a 100644 --- a/tests/run/fused_types.pyx +++ b/tests/run/fused_types.pyx @@ -282,3 +282,18 @@ def test_cython_numeric(cython.numeric arg): double complex (10+1j) """ print cython.typeof(arg), arg + +cdef fused ints_t: + int + long + +cdef _test_index_fused_args(cython.floating f, ints_t i): + print cython.typeof(f), cython.typeof(i) + +def test_index_fused_args(cython.floating f, ints_t i): + """ + >>> import cython + >>> test_index_fused_args[cython.double, cython.int](2.0, 3) + double int + """ + _test_index_fused_args[cython.floating, ints_t](f, i)