Commit ec1c92ee authored by Stefan Behnel's avatar Stefan Behnel

fix cascaded assignments to buffer indices: forgot to reassign the analysed...

fix cascaded assignments to buffer indices: forgot to reassign the analysed (and potentially replaced) node in the tree
parent a9cb5f72
......@@ -5126,8 +5126,8 @@ class CascadedAssignmentNode(AssignmentNode):
# collect distinct types used on the LHS
lhs_types = set()
for lhs in self.lhs_list:
lhs.analyse_target_types(env)
for i, lhs in enumerate(self.lhs_list):
lhs = self.lhs_list[i] = lhs.analyse_target_types(env)
lhs.gil_assignment_check(env)
lhs_types.add(lhs.type)
......
......@@ -483,6 +483,63 @@ def set_int_2d(object[int, ndim=2] buf, int i, int j, int value):
"""
buf[i, j] = value
@testcase
def set_int_2d_cascaded(object[int, ndim=2] buf, int i, int j, int value):
"""
Uses get_int_2d to read back the value afterwards. For pure
unit test, one should support reading in MockBuffer instead.
>>> C = IntMockBuffer("C", range(6), (2,3))
>>> set_int_2d_cascaded(C, 1, 1, 10)
acquired C
released C
10
>>> get_int_2d(C, 1, 1)
acquired C
released C
10
Check negative indexing:
>>> set_int_2d_cascaded(C, -1, 0, 3)
acquired C
released C
3
>>> get_int_2d(C, -1, 0)
acquired C
released C
3
>>> set_int_2d_cascaded(C, -1, -2, 8)
acquired C
released C
8
>>> get_int_2d(C, -1, -2)
acquired C
released C
8
>>> set_int_2d_cascaded(C, -2, -3, 9)
acquired C
released C
9
>>> get_int_2d(C, -2, -3)
acquired C
released C
9
Out-of-bounds errors:
>>> set_int_2d_cascaded(C, 2, 0, 19)
Traceback (most recent call last):
IndexError: Out of bounds on buffer access (axis 0)
>>> set_int_2d_cascaded(C, 0, -4, 19)
Traceback (most recent call last):
IndexError: Out of bounds on buffer access (axis 1)
"""
cdef int casc_value
buf[i, j] = casc_value = value
return casc_value
@testcase
def list_comprehension(object[int] buf, len):
"""
......
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