iteration variable is off by one at end of for loop #284

Closed
opened 2022-04-27 18:02:06 +08:00 by sb10q · 0 comments
from artiq.experiment import *
from artiq.coredevice.core import Core

@nac3
class ForLoop(EnvExperiment):
    core: KernelInvariant[Core]

    def build(self):
        self.setattr_device("core")

    @kernel
    def run(self):
        i = 0
        for i in range(10):
            pass
        print_rpc(i)
> artiq_run foo.py                                                                 
10
>>> for i in range(10):
...   pass
... 
>>> print(i)
9

As I said several times we need tests that exercise corner cases.

``` from artiq.experiment import * from artiq.coredevice.core import Core @nac3 class ForLoop(EnvExperiment): core: KernelInvariant[Core] def build(self): self.setattr_device("core") @kernel def run(self): i = 0 for i in range(10): pass print_rpc(i) ``` ``` > artiq_run foo.py 10 ``` ``` >>> for i in range(10): ... pass ... >>> print(i) 9 ``` As I said several times we need tests that exercise corner cases.
sb10q added this to the Alpha milestone 2022-04-27 18:02:06 +08:00
sb10q closed this issue 2023-09-11 11:27:35 +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#284
There is no content yet.