Commit eef2bc65 authored by Robert Bradshaw's avatar Robert Bradshaw

Fix buffer access bug when indices are mutated during analysis.

parent 899f01f3
...@@ -3421,11 +3421,8 @@ class IndexNode(_IndexingBaseNode): ...@@ -3421,11 +3421,8 @@ class IndexNode(_IndexingBaseNode):
elif base_type.is_buffer and len(indices) == base_type.ndim: elif base_type.is_buffer and len(indices) == base_type.ndim:
# Buffer indexing # Buffer indexing
is_buffer_access = True is_buffer_access = True
for index in indices: indices = [index.analyse_types(env) for index in indices]
index = index.analyse_types(env) if all(index.type.is_int for index in indices):
if not index.type.is_int:
is_buffer_access = False
if is_buffer_access:
replacement_node = BufferIndexNode(self.pos, indices=indices, base=self.base) replacement_node = BufferIndexNode(self.pos, indices=indices, base=self.base)
# On cloning, indices is cloned. Otherwise, unpack index into indices. # On cloning, indices is cloned. Otherwise, unpack index into indices.
assert not isinstance(self.index, CloneNode) assert not isinstance(self.index, CloneNode)
......
...@@ -1184,3 +1184,14 @@ def test_inplace_assignment(): ...@@ -1184,3 +1184,14 @@ def test_inplace_assignment():
buf[0] = get_int() buf[0] = get_int()
print buf[0] print buf[0]
@testcase
def test_nested_assignment():
"""
>>> test_nested_assignment()
100
"""
cdef object[int] inner = IntMockBuffer(None, [1, 2, 3])
cdef object[int] outer = IntMockBuffer(None, [1, 2, 3])
outer[inner[0]] = 100
return outer[inner[0]]
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