From df91500f68fceb2295fb704a96f846d1de46b5c8 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 30 Dec 2015 15:16:05 +0800 Subject: [PATCH] Fix ff3206be. --- artiq/compiler/embedding.py | 3 +-- artiq/compiler/transforms/artiq_ir_generator.py | 5 ++++- artiq/compiler/validators/monomorphism.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 6e6edf3f7..0967cfb5c 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -394,8 +394,7 @@ class StitchingInferencer(Inferencer): IntMonomorphizer(engine=proxy_engine).visit(ast) attr_value_type = ast.type - if is_method: - assert types.is_function(attr_value_type) + if is_method and types.is_rpc_function(attr_value_type): self_type = list(attr_value_type.args.values())[0] self._unify(object_type, self_type, node.loc, None) diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index e0eda3929..66958e544 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -851,8 +851,11 @@ class ARTIQIRGenerator(algorithm.Visitor): if self.current_assign is None: return self.append(ir.GetAttr(obj, node.attr, name="{}.{}".format(_readable_name(obj), node.attr))) + elif types.is_rpc_function(self.current_assign.type): + # RPC functions are just type-level markers + return self.append(ir.Builtin("nop", [], builtins.TNone())) else: - self.append(ir.SetAttr(obj, node.attr, self.current_assign)) + return self.append(ir.SetAttr(obj, node.attr, self.current_assign)) def _map_index(self, length, index, one_past_the_end=False, loc=None): lt_0 = self.append(ir.Compare(ast.Lt(loc=None), diff --git a/artiq/compiler/validators/monomorphism.py b/artiq/compiler/validators/monomorphism.py index e4dd1d853..3eeddfac5 100644 --- a/artiq/compiler/validators/monomorphism.py +++ b/artiq/compiler/validators/monomorphism.py @@ -28,7 +28,7 @@ class MonomorphismValidator(algorithm.Visitor): super().generic_visit(node) if isinstance(node, asttyped.commontyped): - if types.is_polymorphic(node.type): + if types.is_polymorphic(node.type) and not types.is_rpc_function(node.type): note = diagnostic.Diagnostic("note", "the expression has type {type}", {"type": types.TypePrinter().name(node.type)},