-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a freeze primop and stdlib wrapper
Following a confusing behavior around the interaction of recursive fields and dictionary operations (insert, remove, update), it was proposed in #1877 to freeze recursive records before applying dictionary operations. This commit adds a primitive operation to do so, which applies pending contracts, flushes them, and remove any dependency data, effectively freezing recursive fields to their current value. A flag is also added to record attributes, in order to remember that some record has already been frozen. Indeed, freezing is linear in the number of fields and pending contracts: freezing at every dictionary operation thus could be costly. Instead, as for closurization, we do it once and then remember that it's been done in flag. It helps dictionary operations preserve frozenness. Only merging or lazy contract applications might require freezing again.
- Loading branch information
Showing
12 changed files
with
203 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# test.type = 'pass' | ||
[ | ||
(%record/freeze% { x = 1, y = x }) & { x | force = 2 } == { x = 2, y = 1 }, | ||
(%record/freeze% { x | default = 1, y = x }) & { x = 2 } == { x = 2, y = 1 }, | ||
(%record/freeze% { x | default = 1, y = x }) | ||
& (%record/freeze% { x = 2, z = x }) | ||
& { x | force = 3 } == { x = 3, y = 1, z = 2 }, | ||
|
||
# freezing, as record mapping, flushes pending contracts and make them not | ||
# propagate anymore | ||
(%record/freeze% {x | String = "a"}) & {x | force = 1} == {x = 1}, | ||
|
||
] | ||
|> std.test.assert_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# test.type = 'error' | ||
# | ||
# [test.metadata] | ||
# error = 'EvalError::BlameError' | ||
|
||
# Test that even if freezing makes the initial `String` contract to not | ||
# propagate, it doesn't prevent other contracts coming from unfrozen records to | ||
# propagate. | ||
%force% ((%record/freeze% { x | String = "a" }) | ||
& { x | priority 1 | Number = 2 } | ||
& { x | priority 2 = false }) | ||
|