I am trying to access an attribute of a class and get an error that the instance does not have the attribute. My example is a bit more complicated, but I boiled it down to this minimal example:
from artiq.experiment import *
class Foo:
@portable
def __init__(self):
self.bar = 42
class Exp(EnvExperiment):
def build(self):
self.setattr_device("core")
@kernel
def run(self):
foo = Foo()
x = foo.bar # try to access attribute
Here is the error message:
check.py:15:17-15:20: error: type <instance artiq_run_check.Foo {
__objectid__: numpy.int32
}> does not have an attribute 'bar'
x = foo.bar # try to access attribute
~~~ ^^^
I'd expected that foo.bar
yields 42. Why do I see the compiler error?