kernel constructors should be inherited #139

Closed
opened 2021-12-13 23:01:18 +08:00 by sb10q · 0 comments

This fails but should compile:

from min_artiq import *

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


@nac3
class LaserBeamline397pi(LaserBeamline):
    pass


@nac3
class Demo:
    core: KernelInvariant[Core]

    def __init__(self):
        self.core = Core()
        
    @kernel
    def run(self):
        x = LaserBeamline397pi()
        


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

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown identifier LaserBeamline397pi (use before def?) at line 25 column 13"', nac3artiq/src/lib.rs:512:39

Workaround:

@nac3
class LaserBeamline397pi(LaserBeamline):
    @kernel
    def __init__(self):
        pass
This fails but should compile: ```python from min_artiq import * @nac3 class LaserBeamline: @kernel def __init__(self): pass @nac3 class LaserBeamline397pi(LaserBeamline): pass @nac3 class Demo: core: KernelInvariant[Core] def __init__(self): self.core = Core() @kernel def run(self): x = LaserBeamline397pi() if __name__ == "__main__": Demo().run() ``` ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "unknown identifier LaserBeamline397pi (use before def?) at line 25 column 13"', nac3artiq/src/lib.rs:512:39 ``` Workaround: ```python @nac3 class LaserBeamline397pi(LaserBeamline): @kernel def __init__(self): pass ```
sb10q added this to the Alpha milestone 2022-02-28 11:00:04 +08:00
wylited was assigned by sb10q 2022-04-07 13:55:14 +08:00
wylited was unassigned by sb10q 2022-07-04 18:11:27 +08:00
z78078 was assigned by sb10q 2022-07-04 18:11:45 +08:00
sb10q closed this issue 2022-07-28 19:18:36 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
1 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#139
There is no content yet.