Commit 238f9c24 authored by Xavier Thompson's avatar Xavier Thompson

Emit error when a const cypclass reference requires a write lock

parent c6fd6ed8
......@@ -542,6 +542,9 @@ class CypclassLockTransform(Visitor.EnvTransform):
return written_node
ref_id = self.reference_identifier(written_node)
if ref_id:
if ref_id.type.is_const:
error(written_node.pos, "Reference '%s' is const but requires a write lock" % self.id_to_name(ref_id))
return written_node
if not self.wlocked[ref_id] > 0:
if lock_mode == "checklock":
error(written_node.pos, (
......
......@@ -32,6 +32,13 @@ cdef void global_lock_taking():
with wlocked global_cyobject:
global_cyobject.setter(global_cyobject.getter() + 1)
cdef take_non_const(A a):
pass
cdef take_const(const A a):
take_non_const(a)
_ERRORS = u"""
20:4: Reference 'obj' is not correctly locked in this expression (write lock required)
21:4: Reference 'obj' is not correctly locked in this expression (read lock required)
......@@ -40,4 +47,5 @@ _ERRORS = u"""
25:4: Reference 'obj' is not correctly locked in this expression (read lock required)
26:21: Reference 'obj' is not correctly locked in this expression (read lock required)
32:17: Can only lock local variables or arguments
40:19: Reference 'a' is const but requires a write lock
"""
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