Permalink
Browse files

Specialized fused indices

  • Loading branch information...
1 parent 23b8ea6 commit 27d1dcf0077dfb6806ffe016c3705883060bdd5a @markflorisson markflorisson committed Jun 14, 2012
Showing with 24 additions and 0 deletions.
  1. +3 −0 Cython/Compiler/ExprNodes.py
  2. +6 −0 Cython/Compiler/PyrexTypes.py
  3. +15 −0 tests/run/fused_types.pyx
@@ -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")
@@ -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
View
@@ -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)

0 comments on commit 27d1dcf

Please sign in to comment.