compiler: don't crash printing locations of specialized functions.

Fixes #987.
This commit is contained in:
whitequark 2018-04-28 00:49:25 +00:00
parent 8812824fb2
commit f35f100110
2 changed files with 24 additions and 0 deletions

View File

@ -749,6 +749,11 @@ class Stitcher:
quote_function=self._quote_function)
def _function_loc(self, function):
if isinstance(function, SpecializedFunction):
function = function.host_function
if hasattr(function, 'artiq_embedded'):
function = function.artiq_embedded.function
filename = function.__code__.co_filename
line = function.__code__.co_firstlineno
name = function.__code__.co_name

View File

@ -0,0 +1,19 @@
# RUN: %python -m artiq.compiler.testbench.embedding +diag %s 2>%t
# RUN: OutputCheck %s --file-to-check=%t
from artiq.experiment import *
class c():
# CHECK-L: ${LINE:+2}: error: type annotation for argument 'x', 'None', is not an ARTIQ type
@kernel
def hello(self, x: None):
pass
@kernel
def run(self):
self.hello(2)
i = c()
@kernel
def entrypoint():
i.run()