poor error message with tuple indexing #109

Closed
opened 2021-11-23 17:04:57 +08:00 by sb10q · 5 comments
clk_sel_hw_rev: KernelInvariant[tuple[int32, int32, int32, int32]]
clk_sel: int32
...
self.clk_sel = self.clk_sel_hw_rev[self.hw_rev]
pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: "Cannot unify list[var533] with tuple[int32, int32, int32, int32] at line 124 column 28"

var533 should be replaced.

``` clk_sel_hw_rev: KernelInvariant[tuple[int32, int32, int32, int32]] clk_sel: int32 ... self.clk_sel = self.clk_sel_hw_rev[self.hw_rev] ``` ``` pyo3_runtime.PanicException: called `Result::unwrap()` on an `Err` value: "Cannot unify list[var533] with tuple[int32, int32, int32, int32] at line 124 column 28" ``` ``var533`` should be replaced.
Poster
Owner

Still broken (but in a different way).
Try this demo.py:

from min_artiq import *
from numpy import int32


@nac3
class Demo:
    core: KernelInvariant[Core]
    clk_sel_hw_rev: KernelInvariant[tuple[int32, int32, int32, int32]]
    clk_sel: int32

    def __init__(self):
        self.core = Core()
        self.clk_sel_hw_rev = (1, 2, 3, 4)
        self.clk_sel = 2

    @kernel
    def run(self):
        self.clk_sel = self.clk_sel_hw_rev[self.hw_rev]


if __name__ == "__main__":
    Demo().run()
RuntimeError: type error inside object launching kernel: error when getting type of field `clk_sel_hw_rev` (Incompatible types: tuple[int32, int32, int32, int32] and Exception)
Still broken (but in a different way). Try this ``demo.py``: ```python from min_artiq import * from numpy import int32 @nac3 class Demo: core: KernelInvariant[Core] clk_sel_hw_rev: KernelInvariant[tuple[int32, int32, int32, int32]] clk_sel: int32 def __init__(self): self.core = Core() self.clk_sel_hw_rev = (1, 2, 3, 4) self.clk_sel = 2 @kernel def run(self): self.clk_sel = self.clk_sel_hw_rev[self.hw_rev] if __name__ == "__main__": Demo().run() ``` ``` RuntimeError: type error inside object launching kernel: error when getting type of field `clk_sel_hw_rev` (Incompatible types: tuple[int32, int32, int32, int32] and Exception) ```
Poster
Owner

Note that filename and line number are also missing from the message, in addition to the incorrect reference to Exception.

Note that filename and line number are also missing from the message, in addition to the incorrect reference to ``Exception``.
sb10q added the
high-priority
label 2022-02-22 16:29:22 +08:00
sb10q added this to the Prealpha milestone 2022-02-22 16:29:25 +08:00

Well I guess this is due to constant folding and I forgot to add special case for that. Will fix.

Well I guess this is due to constant folding and I forgot to add special case for that. Will fix.
Poster
Owner

It's actually the type annotations that cause this, not self.clk_sel = self.clk_sel_hw_rev[self.hw_rev]

It's actually the type annotations that cause this, not ``self.clk_sel = self.clk_sel_hw_rev[self.hw_rev]``

Fixed, this is due to a typo

Fixed, this is due to a typo
sb10q closed this issue 2022-02-22 17:48:11 +08:00
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#109
There is no content yet.