You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code should not compile. More specifically, we should issue an error when typechecking the val op: ... = ... line, since the function uses the io capability inside its body so it is impure.
The cause of this issue: when type checking the block in the expect[{*} Cap] { ... } expression, the expected type is □ {*} Cap which is boxed, so we will create a temporary boxed Env for it and prevent the captured variable inside the block from charging the outer environment. However, at runtime the block does access the capability io when executing its statements.
Ideally, we should only create a boxed environment when typechecking the expression of the block, but not its statements.
The text was updated successfully, but these errors were encountered:
…6136)
Fixes#16114.
According to the
[comment](#16114 (comment))
in the issue, only create boxed environment when the rechecked tree is a
reference or a function value.
This PR also fixes a testcase, as explained in this
[commit](25daaa8).
Compiler version
main
branchMinimized code
Output
The code compiles.
Expectation
The code should not compile. More specifically, we should issue an error when typechecking the
val op: ... = ...
line, since the function uses theio
capability inside its body so it is impure.The cause of this issue: when type checking the block in the
expect[{*} Cap] { ... }
expression, the expected type is□ {*} Cap
which is boxed, so we will create a temporary boxedEnv
for it and prevent the captured variable inside the block from charging the outer environment. However, at runtime the block does access the capabilityio
when executing its statements.Ideally, we should only create a boxed environment when typechecking the expression of the block, but not its statements.
The text was updated successfully, but these errors were encountered: