From 6938036b2889877b6c46761babff0be4d4d827f5 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 30 Dec 2015 15:38:49 +0800 Subject: [PATCH] embedding: unify all derived attribute types. --- artiq/compiler/embedding.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 0967cfb5c..87941b13c 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -402,18 +402,21 @@ class StitchingInferencer(Inferencer): if node.attr not in attributes: # We just figured out what the type should be. Add it. attributes[node.attr] = attr_value_type - elif attributes[node.attr] != attr_value_type and not types.is_rpc_function(attr_value_type): + elif not types.is_rpc_function(attr_value_type): # Does this conflict with an earlier guess? # RPC function types are exempt because RPCs are dynamically typed. - printer = types.TypePrinter() - diag = diagnostic.Diagnostic("error", - "host object has an attribute '{attr}' of type {typea}, which is" - " different from previously inferred type {typeb} for the same attribute", - {"typea": printer.name(attr_value_type), - "typeb": printer.name(attributes[node.attr]), - "attr": node.attr}, - object_loc) - self.engine.process(diag) + try: + attributes[node.attr].unify(attr_value_type) + except types.UnificationError as e: + printer = types.TypePrinter() + diag = diagnostic.Diagnostic("error", + "host object has an attribute '{attr}' of type {typea}, which is" + " different from previously inferred type {typeb} for the same attribute", + {"typea": printer.name(attr_value_type), + "typeb": printer.name(attributes[node.attr]), + "attr": node.attr}, + object_loc) + self.engine.process(diag) super().visit_AttributeT(node)