Commit 14a5d28b authored by Mark Florisson's avatar Mark Florisson

Don't issue conversion from error type & fix little cython.array cast bug

parent b7c8af96
...@@ -639,7 +639,7 @@ class ExprNode(Node): ...@@ -639,7 +639,7 @@ class ExprNode(Node):
elif src.type.is_array: elif src.type.is_array:
src = CythonArrayNode.from_carray(src, env).coerce_to( src = CythonArrayNode.from_carray(src, env).coerce_to(
dst_type, env) dst_type, env)
else: elif not src_type.is_error:
error(self.pos, error(self.pos,
"Cannot convert '%s' to memoryviewslice" % "Cannot convert '%s' to memoryviewslice" %
(src_type,)) (src_type,))
...@@ -6818,18 +6818,21 @@ class CythonArrayNode(ExprNode): ...@@ -6818,18 +6818,21 @@ class CythonArrayNode(ExprNode):
# Base type of the pointer or C array we are converting # Base type of the pointer or C array we are converting
base_type = self.operand.type base_type = self.operand.type
if not self.operand.type.is_ptr and not self.operand.type.is_array:
return error(self.operand.pos, ERR_NOT_POINTER)
# Dimension sizes of C array # Dimension sizes of C array
array_dimension_sizes = [] array_dimension_sizes = []
if base_type.is_array: if base_type.is_array:
while base_type.is_array: while base_type.is_array:
array_dimension_sizes.append(base_type.size) array_dimension_sizes.append(base_type.size)
base_type = base_type.base_type base_type = base_type.base_type
else: elif base_type.is_ptr:
base_type = base_type.base_type base_type = base_type.base_type
else:
return error()
if not self.operand.type.is_ptr and not self.operand.type.is_array: if not base_type.same_as(array_dtype):
return error(self.operand.pos, ERR_NOT_POINTER)
elif not base_type.same_as(array_dtype):
return error(self.operand.pos, ERR_BASE_TYPE) return error(self.operand.pos, ERR_BASE_TYPE)
elif self.operand.type.is_array and len(array_dimension_sizes) != ndim: elif self.operand.type.is_array and len(array_dimension_sizes) != ndim:
return error(self.operand.pos, return error(self.operand.pos,
...@@ -6859,9 +6862,6 @@ class CythonArrayNode(ExprNode): ...@@ -6859,9 +6862,6 @@ class CythonArrayNode(ExprNode):
self.shapes.append(shape) self.shapes.append(shape)
if not axis.stop.type.is_int:
return error(axis.stop.pos, "Expected an integer type")
first_or_last = axis_no in (0, ndim - 1) first_or_last = axis_no in (0, ndim - 1)
if not axis.step.is_none and first_or_last: if not axis.step.is_none and first_or_last:
axis.step.analyse_types(env) axis.step.analyse_types(env)
......
...@@ -43,6 +43,9 @@ cdef int[:, ::view.contiguous, ::view.indirect_contiguous] a6 ...@@ -43,6 +43,9 @@ cdef int[:, ::view.contiguous, ::view.indirect_contiguous] a6
ctypedef int *intp ctypedef int *intp
cdef intp[:, :] myarray cdef intp[:, :] myarray
cdef int[:] a10 = <int[:10]> object()
cdef int[:] a11 = <int[:5.4]> <int *> 1
# These are VALID # These are VALID
cdef int[::view.indirect_contiguous, ::view.contiguous] a9 cdef int[::view.indirect_contiguous, ::view.contiguous] a9
...@@ -65,4 +68,6 @@ _ERRORS = u''' ...@@ -65,4 +68,6 @@ _ERRORS = u'''
37:9: Only one direct contiguous axis may be specified. 37:9: Only one direct contiguous axis may be specified.
38:9:Only dimensions 3 and 2 may be contiguous and direct 38:9:Only dimensions 3 and 2 may be contiguous and direct
44:10: Invalid base type for memoryview slice: intp 44:10: Invalid base type for memoryview slice: intp
46:35: Can only create cython.array from pointer or array
47:24: Cannot assign type 'double' to 'Py_ssize_t'
''' '''
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