From ca254ec55e49d73e8a9026d76b4d5c7af3af5a6e Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 2 Oct 2017 06:49:13 +0000 Subject: [PATCH] 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. --- artiq/compiler/validators/escape.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artiq/compiler/validators/escape.py b/artiq/compiler/validators/escape.py index b91ef3d3a..de3db9191 100644 --- a/artiq/compiler/validators/escape.py +++ b/artiq/compiler/validators/escape.py @@ -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)