diff --git a/artiq/compiler/embedding.py b/artiq/compiler/embedding.py index 0b903dbe0..ed9ec1ad4 100644 --- a/artiq/compiler/embedding.py +++ b/artiq/compiler/embedding.py @@ -10,6 +10,7 @@ from collections import OrderedDict, defaultdict from pythonparser import ast, algorithm, source, diagnostic, parse_buffer +from ..language import core as language_core from . import types, builtins, asttyped, prelude from .transforms import ASTTypedRewriter, Inferencer, IntMonomorphizer diff --git a/artiq/compiler/transforms/inferencer.py b/artiq/compiler/transforms/inferencer.py index aa726e98f..852617c5e 100644 --- a/artiq/compiler/transforms/inferencer.py +++ b/artiq/compiler/transforms/inferencer.py @@ -91,9 +91,22 @@ class Inferencer(algorithm.Visitor): object_type = node.value.type.find() if not types.is_var(object_type): if node.attr in object_type.attributes: + def makenotes(printer, typea, typeb, loca, locb): + return [ + diagnostic.Diagnostic("note", + "expression of type {typea}", + {"typea": printer.name(typea)}, + loca), + diagnostic.Diagnostic("note", + "expression of type {typeb}", + {"typeb": printer.name(object_type)}, + node.value.loc) + ] + # Assumes no free type variables in .attributes. self._unify(node.type, object_type.attributes[node.attr], - node.loc, None) + node.loc, None, + makenotes=makenotes, when=" for attribute '{}'".format(node.attr)) elif types.is_instance(object_type) and \ node.attr in object_type.constructor.attributes: # Assumes no free type variables in .attributes.