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

Fix memoryview casts involving fused types (GH-3882)

I think this approach is more satisfactory than the old way it used to "work", where "fused_to_specific" was permanently added to the module scope containing the fused type (in this case the Cython scope), was applied in "Scope.lookup_type", but continued to have an effect on the scope forever.

Closes https://github.com/cython/cython/issues/3881
parent a9699f74
......@@ -1048,6 +1048,8 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
type = PyrexTypes.TemplatePlaceholderType(self.name)
else:
error(self.pos, "'%s' is not a type identifier" % self.name)
if type and type.is_fused and env.fused_to_specific:
type = type.specialize(env.fused_to_specific)
if self.complex:
if not type.is_numeric or type.is_complex:
error(self.pos, "can only complexify c numeric types")
......
......@@ -326,6 +326,8 @@ def test_fused_memslice_dtype(cython.floating[:] array):
cdef cython.floating[:] otherarray = array[0:100:1]
print cython.typeof(array), cython.typeof(otherarray), \
array[5], otherarray[6]
cdef cython.floating value;
cdef cython.floating[:] test_cast = <cython.floating[:1:1]>&value
def test_fused_memslice_dtype_repeated(cython.floating[:] array1, cython.floating[:] array2):
"""
......
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