Option::unwrap()
on a None
value panic with typevars #219
sb10q
commented 2022-03-17 20:56:33 +08:00
Owner
```
diff --git a/artiq/coredevice/ad9910.py b/artiq/coredevice/ad9910.py
index 23d2856f..0adb5740 100644
--- a/artiq/coredevice/ad9910.py
+++ b/artiq/coredevice/ad9910.py
@@ -1,3 +1,5 @@
+from typing import TypeVar, Generic
+
from numpy import int32, int64
from artiq.language.core import *
@@ -61,6 +63,7 @@ RAM_MODE_CONT_RAMPUP = 4
# Default profile for RAM mode
_DEFAULT_PROFILE_RAM = 0
+
@nac3
class SyncDataUser:
core: KernelInvariant[Core]
@@ -110,8 +113,11 @@ class SyncDataEeprom:
self.io_update_delay = int32(io_update_delay)
+SyncData = TypeVar("SyncData", SyncDataUser, SyncDataEeprom)
+
+
@nac3
-class AD9910:
+class AD9910(Generic[SyncData]):
"""
AD9910 DDS channel on Urukul.
@@ -159,7 +165,7 @@ class AD9910:
sysclk_per_mu: KernelInvariant[int32]
sysclk: KernelInvariant[float]
sw: KernelInvariant[TTLOut]
- sync_data: KernelInvariant[SyncDataUser]
+ sync_data: KernelInvariant[SyncData]
phase_mode: Kernel[int32]
def __init__(self, dmgr, chip_select, cpld_device, sw_device=None,
@@ -198,7 +204,6 @@ class AD9910:
self.sysclk_per_mu = int(round(sysclk * self.core.ref_period))
self.sysclk = sysclk
- # NAC3TODO
if isinstance(sync_delay_seed, str) or isinstance(io_update_delay,
str):
if sync_delay_seed != io_update_delay:
diff --git a/artiq/examples/nac3devices/nac3devices.py b/artiq/examples/nac3devices/nac3devices.py
index caf65aba..f68800ea 100644
--- a/artiq/examples/nac3devices/nac3devices.py
+++ b/artiq/examples/nac3devices/nac3devices.py
@@ -7,7 +7,7 @@ from artiq.coredevice.mirny import Mirny as MirnyCPLD
from artiq.coredevice.adf5356 import ADF5356
from artiq.coredevice.urukul import CPLD as UrukulCPLD
from artiq.coredevice.ad9912 import AD9912
-from artiq.coredevice.ad9910 import AD9910
+from artiq.coredevice.ad9910 import AD9910, SyncDataUser
from artiq.coredevice.sampler import Sampler
from artiq.coredevice.edge_counter import EdgeCounter
from artiq.coredevice.grabber import Grabber
@@ -26,7 +26,7 @@ class NAC3Devices(EnvExperiment):
eeprom_urukul0: KernelInvariant[KasliEEPROM]
urukul0_ch0: KernelInvariant[AD9912]
urukul1_cpld: KernelInvariant[UrukulCPLD]
- urukul1_ch0: KernelInvariant[AD9910]
+ urukul1_ch0: KernelInvariant[AD9910[SyncDataUser]]
sampler0: KernelInvariant[Sampler]
ttl0_counter: KernelInvariant[EdgeCounter]
grabber0: KernelInvariant[Grabber]
```
```
> artiq_compile nac3devices.py
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', nac3core/src/typecheck/type_inferencer/mod.rs:885:67
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/nix/store/bli9zvl4qxajn6cmc4kangwyr2cv0y7h-python3.9-artiq-8.0.unknown.beta/bin/.artiq_compile-wrapped", line 9, in <module>
sys.exit(main())
File "/home/sb/artiq/artiq/frontend/artiq_compile.py", line 66, in main
exp_inst.core.compile(exp_inst.run, [], {}, embedding_map, file_output=output)
File "/home/sb/artiq/artiq/coredevice/core.py", line 80, in compile
self.compiler.compile_method_to_file(obj, name, args, file_output, embedding_map)
pyo3_runtime.PanicException: called `Option::unwrap()` on a `None` value
```
sb10q
referenced this issue 2022-03-17 21:45:47 +08:00
'internal error: entered unreachable code: TVar', nac3core/src/codegen/mod.rs:322:18 #222
pca006132
closed this issue 2022-03-18 01:09:47 +08:00
Labels
No Milestone
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: M-Labs/nac3#219
Loading…
Reference in New Issue
There is no content yet.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?