virtual is broken for host attributes #138

Closed
opened 2021-12-13 22:55:17 +08:00 by sb10q · 3 comments
from numpy import int32
from min_artiq import *

@nac3
class LaserBeamline:
    @kernel
    def set_dds_on(self):
        print_int32(32)

    @kernel
    def set_dac_on(self):
        print_int32(35)

@nac3
class LaserBeamline397pi(LaserBeamline):
    pass

@nac3
class LaserBeamline866(LaserBeamline):
    pass

@nac3
class Demo:
    core: KernelInvariant[Core]
    beamlines: list[virtual[LaserBeamline]]

    def __init__(self):
        self.core = Core()
        self.beamlines = [LaserBeamline397pi(), LaserBeamline866()]

    @kernel
    def run(self):
        for beamline in self.beamlines:
            beamline.set_dds_on()
            beamline.set_dac_on()


if __name__ == "__main__":
    Demo().run()

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown identifier base (use before def?) at line 2 column 5"', nac3artiq/src/lib.rs:512:39
```python from numpy import int32 from min_artiq import * @nac3 class LaserBeamline: @kernel def set_dds_on(self): print_int32(32) @kernel def set_dac_on(self): print_int32(35) @nac3 class LaserBeamline397pi(LaserBeamline): pass @nac3 class LaserBeamline866(LaserBeamline): pass @nac3 class Demo: core: KernelInvariant[Core] beamlines: list[virtual[LaserBeamline]] def __init__(self): self.core = Core() self.beamlines = [LaserBeamline397pi(), LaserBeamline866()] @kernel def run(self): for beamline in self.beamlines: beamline.set_dds_on() beamline.set_dac_on() if __name__ == "__main__": Demo().run() ``` ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown identifier base (use before def?) at line 2 column 5"', nac3artiq/src/lib.rs:512:39 ```
Poster
Owner

Actually, how is one supposed to use virtual at all? This also fails:

from numpy import int32
from min_artiq import *

@nac3
class LaserBeamline:
    @kernel
    def __init__(self):
        pass

    @kernel
    def set_dds_on(self):
        print_int32(32)

    @kernel
    def set_dac_on(self):
        print_int32(35)

@nac3
class LaserBeamline397pi(LaserBeamline):
    @kernel
    def __init__(self):
        pass

@nac3
class LaserBeamline866(LaserBeamline):
    @kernel
    def __init__(self):
        pass

@nac3
class Demo:
    core: KernelInvariant[Core]

    def __init__(self):
        self.core = Core()
        
    @kernel
    def foo(self, beamlines: list[virtual[LaserBeamline]]):
        for beamline in beamlines:
            beamline.set_dds_on()
            beamline.set_dac_on()

    @kernel
    def run(self):
        beamlines = [LaserBeamline397pi(), LaserBeamline866()]
        self.foo(beamlines)
        


if __name__ == "__main__":
    Demo().run()
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Cannot unify LaserBeamline397pi with LaserBeamline866 at line 45 column 90"', nac3artiq/src/lib.rs:512:39

Actually, how is one supposed to use ``virtual`` at all? This also fails: ```python from numpy import int32 from min_artiq import * @nac3 class LaserBeamline: @kernel def __init__(self): pass @kernel def set_dds_on(self): print_int32(32) @kernel def set_dac_on(self): print_int32(35) @nac3 class LaserBeamline397pi(LaserBeamline): @kernel def __init__(self): pass @nac3 class LaserBeamline866(LaserBeamline): @kernel def __init__(self): pass @nac3 class Demo: core: KernelInvariant[Core] def __init__(self): self.core = Core() @kernel def foo(self, beamlines: list[virtual[LaserBeamline]]): for beamline in beamlines: beamline.set_dds_on() beamline.set_dac_on() @kernel def run(self): beamlines = [LaserBeamline397pi(), LaserBeamline866()] self.foo(beamlines) if __name__ == "__main__": Demo().run() ``` ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Cannot unify LaserBeamline397pi with LaserBeamline866 at line 45 column 90"', nac3artiq/src/lib.rs:512:39 ```

We haven't yet implemented virtual.

We haven't yet implemented virtual.

I guess we should close it as this is a dup of #69

I guess we should close it as this is a dup of #69
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#138
There is no content yet.