From 5000f87dfc67850bc289120bffb749129be68d21 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 16 Jul 2015 14:55:23 +0300 Subject: [PATCH] Rename the field of CoerceT from expr to value. --- artiq/compiler/asttyped.py | 2 +- artiq/compiler/transforms/inferencer.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/artiq/compiler/asttyped.py b/artiq/compiler/asttyped.py index 8e4674c99..7d38bd823 100644 --- a/artiq/compiler/asttyped.py +++ b/artiq/compiler/asttyped.py @@ -92,4 +92,4 @@ class YieldFromT(ast.YieldFrom, commontyped): # Novel typed nodes class CoerceT(ast.expr, commontyped): - _fields = ('expr',) # other_expr deliberately not in _fields + _fields = ('value',) # other_value deliberately not in _fields diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index 45d2cf40e..cc224bb07 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -186,17 +186,17 @@ class Inferencer(algorithm.Visitor): def visit_CoerceT(self, node): self.generic_visit(node) - if builtins.is_numeric(node.type) and builtins.is_numeric(node.expr.type): + if builtins.is_numeric(node.type) and builtins.is_numeric(node.value.type): pass else: printer = types.TypePrinter() note = diagnostic.Diagnostic("note", "expression that required coercion to {typeb}", {"typeb": printer.name(node.type)}, - node.other_expr.loc) + node.other_value.loc) diag = diagnostic.Diagnostic("error", "cannot coerce {typea} to {typeb}", - {"typea": printer.name(node.expr.type), "typeb": printer.name(node.type)}, + {"typea": printer.name(node.value.type), "typeb": printer.name(node.type)}, node.loc, notes=[note]) self.engine.process(diag) @@ -205,9 +205,9 @@ class Inferencer(algorithm.Visitor): return coerced_node elif isinstance(coerced_node, asttyped.CoerceT): node = coerced_node - node.type, node.other_expr = typ, other_node + node.type, node.other_value = typ, other_node else: - node = asttyped.CoerceT(type=typ, expr=coerced_node, other_expr=other_node, + node = asttyped.CoerceT(type=typ, value=coerced_node, other_value=other_node, loc=coerced_node.loc) self.visit(node) return node @@ -217,7 +217,7 @@ class Inferencer(algorithm.Visitor): node_types = [] for node in nodes: if isinstance(node, asttyped.CoerceT): - node_types.append(node.expr.type) + node_types.append(node.value.type) else: node_types.append(node.type) if any(map(types.is_var, node_types)): # not enough info yet