If expression fix (#249) #250

Merged
sb10q merged 2 commits from if_expr_fix into master 2022-03-29 06:54:00 +08:00
Collaborator

Use store and load to handle if expression as the blocks might be changed when generating sub-expressions.

this will also fix nested if expressions like this:

@nac3
class Demo:
    core: KernelInvariant[Core]
    v: Kernel[Option[int32]]
    def __init__(self):
        self.core = Core()
        self.v = Some(9)

    @kernel
    def run(self):
        d = (4 if True else 5) if False else (6 if True else 7)
        print_int32(d)

which will just cause segfault

Use store and load to handle if expression as the blocks might be changed when generating sub-expressions. this will also fix nested if expressions like this: ```python @nac3 class Demo: core: KernelInvariant[Core] v: Kernel[Option[int32]] def __init__(self): self.core = Core() self.v = Some(9) @kernel def run(self): d = (4 if True else 5) if False else (6 if True else 7) print_int32(d) ``` which will just cause segfault
ychenfo added 1 commit 2022-03-28 23:27:20 +08:00
ychenfo changed title from If expresion fix (#249) to If expression fix (#249) 2022-03-28 23:48:54 +08:00
ychenfo force-pushed if_expr_fix from 87fe8e730c to b7e694d09c 2022-03-29 00:31:07 +08:00 Compare
sb10q merged commit 1f5826d352 into master 2022-03-29 06:54:00 +08:00
sb10q deleted branch if_expr_fix 2022-03-29 06:54:00 +08:00
sb10q referenced this issue from a commit 2022-03-29 06:54:01 +08:00
Sign in to join this conversation.
No reviewers
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#250
There is no content yet.