Commit b9cecd60 authored by da-woods's avatar da-woods Committed by GitHub

Fixed reference types being passed to getitemint (GH-3755)

parent 12a2ad5a
......@@ -3739,6 +3739,8 @@ class IndexNode(_IndexingBaseNode):
if not base_type.is_cfunction:
self.index = self.index.analyse_types(env)
self.original_index_type = self.index.type
if self.original_index_type.is_reference:
self.original_index_type = self.original_index_type.ref_base_type
if base_type.is_unicode_char:
# we infer Py_UNICODE/Py_UCS4 for unicode strings in some
......
......@@ -28,3 +28,15 @@ def test_lvalue_ref_assignment():
assert bar[0] == &baz[0][0]
assert bar[0][0] == bongle
# not *strictly* lvalue refs but this file seems the closest applicable place for it.
# GH 3754 - std::vector operator[] returns a reference, and this causes problems if
# the reference is passed into Cython __Pyx_GetItemInt
def test_ref_used_for_indexing():
"""
>>> test_ref_used_for_indexing()
'looked up correctly'
"""
cdef vector[int] idx = [1,2,3]
d = {1: "looked up correctly", 2:"oops"}
return d[idx[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