-
Notifications
You must be signed in to change notification settings - Fork 468
Open
Labels
bugSomething isn't workingSomething isn't workingcompilationCompilation of terms and functions to HVMCompilation of terms and functions to HVM
Description
Reproducing the behavior
This excerpt:
def main():
with IO:
x <- wrap(1)
return wrap(wrap(2))
Should be desugaring to
(main) = (IO/bind (IO/wrap 1) λa (a λ* (IO/wrap (IO/wrap 2))))
Instead it desugars into
(main) = (IO/bind (IO/wrap 1) λa (a λb let {c d} = b; λ* (c (d 2)) IO/wrap))
wrap is seen as a free variable, so it gets applied in a deferred way as well as duplicated if it's used more than once.
We need to first substitute the wrap and only then desugar the bind.
System Settings
Bend commit 270f39c
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcompilationCompilation of terms and functions to HVMCompilation of terms and functions to HVM