summaryrefslogtreecommitdiff
path: root/tests/run/lvalue_refs.pyx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/lvalue_refs.pyx')
-rw-r--r--tests/run/lvalue_refs.pyx12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/run/lvalue_refs.pyx b/tests/run/lvalue_refs.pyx
index d42f2407e..6bd0d88bc 100644
--- a/tests/run/lvalue_refs.pyx
+++ b/tests/run/lvalue_refs.pyx
@@ -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]]