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

Remove ban on assignment to reference (GH-3987)

Fixes https://github.com/cython/cython/issues/1863
parent ea43f8ef
......@@ -2136,8 +2136,6 @@ class NameNode(AtomicExprNode):
if self.type.is_const:
error(self.pos, "Assignment to const '%s'" % self.name)
if self.type.is_reference:
error(self.pos, "Assignment to reference '%s'" % self.name)
if not self.is_lvalue():
error(self.pos, "Assignment to non-lvalue '%s'" % self.name)
self.type = PyrexTypes.error_type
......
......@@ -29,6 +29,18 @@ def test_lvalue_ref_assignment():
assert bar[0] == &baz[0][0]
assert bar[0][0] == bongle
cdef void assign_to_basic_reference(int& ref):
ref = 123
def test_assign_to_basic_ref():
"""
>>> test_assign_to_basic_ref()
123
"""
cdef int x=0
assign_to_basic_reference(x)
print x
# 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
......
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