2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 11:18:27 +08:00

compiler: disallow op= on mutable lists only (fix #835).

This only really applies to lists since those use fat pointers.
`x.y += z` is fine.
This commit is contained in:
whitequark 2017-10-02 06:49:13 +00:00
parent cda9719f4b
commit ca254ec55e

View File

@ -330,7 +330,7 @@ class EscapeValidator(algorithm.Visitor):
self.visit_assignment(target, node.value)
def visit_AugAssign(self, node):
if builtins.is_allocated(node.target.type):
if builtins.is_list(node.target.type):
note = diagnostic.Diagnostic("note",
"try using `{lhs} = {lhs} {op} {rhs}` instead",
{"lhs": node.target.loc.source(),
@ -338,7 +338,7 @@ class EscapeValidator(algorithm.Visitor):
"op": node.op.loc.source()[:-1]},
node.loc)
diag = diagnostic.Diagnostic("error",
"values cannot be mutated in-place", {},
"lists cannot be mutated in-place", {},
node.op.loc, [node.target.loc],
notes=[note])
self.engine.process(diag)