deriving from EnvExperiment causes compilation failure #80

Closed
opened 2021-11-10 12:28:50 +08:00 by sb10q · 5 comments

Experiments in ARTIQ derive from EnvExperiment, and this is currently incompatible with NAC3. The compiler fails with this rather obscure error message:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "name cannot be parsed as a type annotation"', nac3artiq/src/lib.rs:378:44

Should we just ignore ancestor classes that are not decorated with @nac3?

Experiments in ARTIQ derive from ``EnvExperiment``, and this is currently incompatible with NAC3. The compiler fails with this rather obscure error message: ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "name cannot be parsed as a type annotation"', nac3artiq/src/lib.rs:378:44 ``` Should we just ignore ancestor classes that are not decorated with ``@nac3``?
sb10q added the
high-priority
label 2021-11-10 12:28:50 +08:00
Poster
Owner

and decorating EnvExperiment and its ancestors with @nac3 fails with:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "a class def can only have at most one base class declaration and one generic declaration"', nac3artiq/src/lib.rs:378:44

Removing the Experiment ancestor works around the problem.

and decorating ``EnvExperiment`` and its ancestors with ``@nac3`` fails with: ``` thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "a class def can only have at most one base class declaration and one generic declaration"', nac3artiq/src/lib.rs:378:44 ``` Removing the ``Experiment`` ancestor works around the problem.
Poster
Owner

Should we just ignore ancestor classes that are not decorated with @nac3?

Doing it naively may not be a good idea because it would silently ignore ancestors where the user made a typo in the class name. If we go this route we should at least check that the ancestor class exists on the CPython side and raise an error if it does not.

> Should we just ignore ancestor classes that are not decorated with @nac3? Doing it naively may not be a good idea because it would silently ignore ancestors where the user made a typo in the class name. If we go this route we should at least check that the ancestor class exists on the CPython side and raise an error if it does not.
Collaborator

Currently in nac3core, the @nac3 annotated classes only allow single inheritance to prevent some troubles from multiple inheritance.(I am not sure... but should we relax this limitation to allow multiple inheritance, but only permit the cases that at most one of the base classes can be constructed on the kernel (have their constructor annotated by @kernel)?)

For nac3artiq, I think if the user made a typo, the python interpreter would complain so we can safely ignore those not decorated with @nac3 and do not check anything in nac3core?

For nac3standalone, I think the check is still necessary now and it would not be a good idea if we ignore them...

So maybe the nac3core needs to have two modes? Under the mode for nac3artiq it ignores the base class not decorated in @nac3, under the mode for standalone it does not?

Currently in nac3core, the `@nac3` annotated classes only allow single inheritance to prevent some troubles from multiple inheritance.(I am not sure... but should we relax this limitation to allow multiple inheritance, but only permit the cases that at most one of the base classes can be constructed on the kernel (have their constructor annotated by `@kernel`)?) For nac3artiq, I think if the user made a typo, the python interpreter would complain so we can safely ignore those not decorated with `@nac3` and do not check anything in nac3core? For nac3standalone, I think the check is still necessary now and it would not be a good idea if we ignore them... So maybe the nac3core needs to have two modes? Under the mode for nac3artiq it ignores the base class not decorated in `@nac3`, under the mode for standalone it does not?

What about filtering out ancestor classes that are not decorated with nac3 in nac3artiq? Just a set of class python IDs that are annotated with nac3, so we can filter out those that are not annotated.

What about filtering out ancestor classes that are not decorated with nac3 in nac3artiq? Just a set of class python IDs that are annotated with nac3, so we can filter out those that are not annotated.
Poster
Owner

@pca006132 Sounds good.

@pca006132 Sounds good.
sb10q closed this issue 2021-11-11 16:08:45 +08:00
Sign in to join this conversation.
No Milestone
No Assignees
3 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#80
There is no content yet.