Skip to content

Commit

Permalink
embedding: unify all derived attribute types.
Browse files Browse the repository at this point in the history
whitequark committed Dec 30, 2015
1 parent f52d364 commit 6938036
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions artiq/compiler/embedding.py
Original file line number Diff line number Diff line change
@@ -402,18 +402,21 @@ def proxy_diagnostic(diag):
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)

0 comments on commit 6938036

Please sign in to comment.